|
|
@ -21,26 +21,67 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
public class RenException extends RuntimeException { |
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
private int code; |
|
|
|
/** |
|
|
|
* 显示给客户的消息 |
|
|
|
*/ |
|
|
|
private String msg; |
|
|
|
/** |
|
|
|
* 内部消息,用于服务之间传递错误信息,排错用 |
|
|
|
*/ |
|
|
|
private String internalMsg; |
|
|
|
|
|
|
|
public RenException(int code) { |
|
|
|
this(code, ""); |
|
|
|
} |
|
|
|
|
|
|
|
public RenException(int code, String internalMsg) { |
|
|
|
super(internalMsg); |
|
|
|
this.code = code; |
|
|
|
if (StringUtils.isBlank(internalMsg)) { |
|
|
|
this.internalMsg = EpmetErrorCode.getMsg(code); |
|
|
|
if (StringUtils.isBlank(this.internalMsg)) { |
|
|
|
this.internalMsg = MessageUtils.getMessage(code, internalMsg); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.internalMsg = internalMsg; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public RenException(int code, String internalMsg, String msg) { |
|
|
|
this(code, internalMsg); |
|
|
|
this.msg = msg; |
|
|
|
} |
|
|
|
|
|
|
|
public RenException(String internalMsg) { |
|
|
|
super(internalMsg); |
|
|
|
// this.code = ErrorCode.INTERNAL_SERVER_ERROR;
|
|
|
|
this.code = EpmetErrorCode.SERVER_ERROR.getCode(); |
|
|
|
this.internalMsg = internalMsg; |
|
|
|
} |
|
|
|
|
|
|
|
public RenException(String internalMsg, String msg) { |
|
|
|
this(internalMsg); |
|
|
|
this.msg = msg; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public RenException(int code, String... params) { |
|
|
|
this.code = code; |
|
|
|
this.msg = EpmetErrorCode.getMsg(code); |
|
|
|
if (StringUtils.isBlank(this.msg)) { |
|
|
|
this.msg = MessageUtils.getMessage(code, params); |
|
|
|
this.internalMsg = EpmetErrorCode.getMsg(code); |
|
|
|
if (StringUtils.isBlank(this.internalMsg)) { |
|
|
|
this.internalMsg = MessageUtils.getMessage(code, params); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public RenException(int code, Throwable e) { |
|
|
|
super(e); |
|
|
|
this.code = code; |
|
|
|
this.msg = EpmetErrorCode.getMsg(code); |
|
|
|
if (StringUtils.isBlank(this.msg)) { |
|
|
|
this.msg = MessageUtils.getMessage(code); |
|
|
|
this.internalMsg = EpmetErrorCode.getMsg(code); |
|
|
|
if (StringUtils.isBlank(this.internalMsg)) { |
|
|
|
this.internalMsg = MessageUtils.getMessage(code); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -50,40 +91,18 @@ public class RenException extends RuntimeException { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public RenException(int code, String msg) { |
|
|
|
super(msg); |
|
|
|
this.code = code; |
|
|
|
if (StringUtils.isBlank(msg)) { |
|
|
|
this.msg = EpmetErrorCode.getMsg(code); |
|
|
|
if (StringUtils.isBlank(this.msg)) { |
|
|
|
this.msg = MessageUtils.getMessage(code, msg); |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.msg = msg; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public RenException(String msg) { |
|
|
|
super(msg); |
|
|
|
// this.code = ErrorCode.INTERNAL_SERVER_ERROR;
|
|
|
|
public RenException(String internalMsg, Throwable e) { |
|
|
|
super(internalMsg, e); |
|
|
|
this.code = EpmetErrorCode.SERVER_ERROR.getCode(); |
|
|
|
this.msg = msg; |
|
|
|
this.internalMsg = internalMsg; |
|
|
|
} |
|
|
|
|
|
|
|
public RenException(String msg, Throwable e) { |
|
|
|
super(msg, e); |
|
|
|
// this.code = ErrorCode.INTERNAL_SERVER_ERROR;
|
|
|
|
this.code = EpmetErrorCode.SERVER_ERROR.getCode(); |
|
|
|
this.msg = msg; |
|
|
|
public String getInternalMsg() { |
|
|
|
return internalMsg; |
|
|
|
} |
|
|
|
|
|
|
|
public String getMsg() { |
|
|
|
return msg; |
|
|
|
} |
|
|
|
|
|
|
|
public void setMsg(String msg) { |
|
|
|
this.msg = msg; |
|
|
|
public void setInternalMsg(String internalMsg) { |
|
|
|
this.internalMsg = internalMsg; |
|
|
|
} |
|
|
|
|
|
|
|
public int getCode() { |
|
|
@ -94,4 +113,11 @@ public class RenException extends RuntimeException { |
|
|
|
this.code = code; |
|
|
|
} |
|
|
|
|
|
|
|
public String getMsg() { |
|
|
|
return msg; |
|
|
|
} |
|
|
|
|
|
|
|
public void setMsg(String msg) { |
|
|
|
this.msg = msg; |
|
|
|
} |
|
|
|
} |
|
|
|