Commit 9fa04351 authored by yanzg's avatar yanzg

修改请求错误的显示

parent 0abb62e8
......@@ -58,6 +58,36 @@ public class CodeException extends RuntimeException {
this.code = code;
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param message  错误消息
* @param target  错误数据源,如订单数据
*/
public CodeException(String message, Object target) {
super(message);
this.target = target;
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param message  错误消息
* @param target  错误数据源,如订单数据
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public CodeException(String message, Object target, Throwable cause) {
super(message, cause);
this.target = target;
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
......@@ -73,6 +103,25 @@ public class CodeException extends RuntimeException {
this.target = target;
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param code  错误码
* @param message  错误消息
* @param target  错误数据源,如订单数据
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public CodeException(String code, String message, Object target, Throwable cause) {
super(message, cause);
this.code = code;
this.target = target;
}
/**
* Constructs a new runtime exception with the specified detail message and
* cause. <p>Note that the detail message associated with
......
package com.yanzuoguang.util.exception;
/**
* 途比达异常信息
*
* @author 颜佐光
*/
public class HttpCodeException extends RuntimeException {
private static final long serialVersionUID = -4625832188480820883L;
/**
* 错误码
*/
private String code = "99";
/**
* 包含的数据
*/
private Object target = null;
/**
* 获取错误码
*
* @return 返回的结果
*/
public String getCode() {
return this.code;
}
/**
* 来源数据
*
* @return
*/
public Object getTarget() {
return target;
}
/**
* 构造函数
* throw new CodeException("01","该订单已过期",order);
* throw new CodeException("02","该订单未到使用时间",order);
*
* @param code  错误码
* @param message  错误消息
* @param target  错误数据源,如订单数据
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
*/
public HttpCodeException(String code, String message, Object target, Throwable cause) {
super(message, cause);
this.code = code;
this.target = target;
}
}
package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.exception.HttpCodeException;
import com.yanzuoguang.util.thread.ProcessData;
import com.yanzuoguang.util.thread.RunProcess;
import javax.xml.ws.http.HTTPException;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
......@@ -100,7 +103,7 @@ public class HttpHelper {
in = readStream(httpConn.getInputStream(), result);
} catch (Exception ex) {
in = readStream(httpConn.getErrorStream(), result);
throw new RuntimeException(ex.getMessage() + " 结果:" + result.toString(), ex);
throw new HttpCodeException(StringHelper.toString(httpConn.getResponseCode()), ex.getMessage(), result.toString(), ex);
} finally {
if (out != null) {
out.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment