1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package cn.wisenergy.chnmuseum.party.common.mvc;
import cn.wisenergy.chnmuseum.party.common.enums.RESPONSE_CODE_ENUM;
/**
* 自定义接口异常对象
*/
public class InterfaceException extends RuntimeException {
private static final long serialVersionUID = -854533489101542484L;
// 错误编码
private String errorCode;
// 错误编码信息
private String errorMsg;
/**
* 应用接口有参构造函数
*
* @param errorMsg 错误信息
*/
public InterfaceException(String errorMsg) {
super(" errorMsg:" + errorMsg);
this.errorCode = "500";
this.errorMsg = errorMsg;
}
/**
* 应用接口有参构造函数
*
* @param errorCode 错误编码
* @param errorMsg 错误信息
*/
public InterfaceException(String errorCode, String errorMsg) {
super("errorCode:" + errorCode + " errorMsg:" + errorMsg);
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
/**
* 应用接口有参构造函数
*
* @param responseCode 响应编码枚举
*/
public InterfaceException(RESPONSE_CODE_ENUM responseCode) {
super("errorCode:" + responseCode.getResultCode() + " errorMsg:" + responseCode.getMessage());
this.errorCode = responseCode.getResultCode();
this.errorMsg = responseCode.getMessage();
}
/**
* 获取错误编码
*/
public String getErrorCode() {
return errorCode;
}
/**
* 设置错误编码
*/
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
/**
* 获取异常编码
*/
public String getErrorMsg() {
return errorMsg;
}
/**
* 设置异常编码
*/
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
}