/**
* Created by gfj43958 on 2017/1/6.
*/
public enum WrapperEnumError {
//网络超时
SOCKET_TIMEOUT("W001", "网络超时"),
//网络链接异常
SOCKET_CONNECT_EROOR("W002", "网络链接异常"),
//请求参数错误
REQUEST_ARGUMENTS_ERROR("W003", "请求参数错误"),
//WSDL错误
WDSL_ERROR("W004", "wsdl地址错误"),
//Session创建失败
SESSION_CREATE_ERROR("W006", "未知错误,session创建失败"),
//session关闭失败
SESSION_CLOSE_ERROR("W007", "未知错误,session关闭失败"),
//token创建失败
TOKEN_CREATE_ERROR("W008", "未知错误,token创建失败"),
//token关闭失败
TOKEN_CLOSE_ERROR("W009", "未知错误,token关闭失败"),
//未知错误
OTHER_ERROR("W400", "其他错误"),
private String errorCode;
private String errorMsg;
private String code;
private String msg;
private WrapperEnumError(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
public static String getResponseMsg(String code) {
for (WrapperEnumError wrapperEnumError : WrapperEnumError.values()) {
if (code.equals(wrapperEnumError.getCode())) {
return wrapperEnumError.getMsg();
}
}
return OTHER_ERROR.getMsg();
}
}
一个用枚举类型定义错误码的Demo
最新推荐文章于 2023-12-20 15:29:55 发布