添加表内的异常返回类型
parent
4806c9d71e
commit
0eb673e594
|
@ -226,6 +226,10 @@ public enum ErrorCode implements IErrorCode {
|
||||||
this.errMsg = errMsg;
|
this.errMsg = errMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCodeId(int codeId) {
|
||||||
|
this.codeId = codeId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int code() {
|
public int code() {
|
||||||
return codeId;
|
return codeId;
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ErrorCodeException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[CODE: " + this.errorCode.code() + "][" + this.errorCode.message() + "][" +((super.getMessage()==null)?"":super.getMessage())+ "][" +((params!=null&¶ms.size()!=0)?params.toString():"")+"] ";
|
return "[CODE: " + this.errorCode.code() + "][" + this.errorCode.message() + "][" +((super.getMessage()==null)?"":super.getMessage())+ "][" +((params!=null&& !params.isEmpty())?params.toString():"")+"] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getParams() {
|
public List<String> getParams() {
|
||||||
|
@ -75,6 +75,6 @@ public class ErrorCodeException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return "" + super.getMessage();
|
return super.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
package com.ljsd.jieling.exception;
|
||||||
|
|
||||||
|
import config.SErrorCodeEerverConfig;
|
||||||
|
import util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 逻辑异常包装类
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2019/10/21 11:44
|
||||||
|
*/
|
||||||
|
public class ErrorTableException extends Exception {
|
||||||
|
private int id;
|
||||||
|
private String msg;
|
||||||
|
private List<String> params;
|
||||||
|
|
||||||
|
public ErrorTableException(int id, String msg) {
|
||||||
|
this.id = id;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorTableException(int id, String msg, List<String> params) {
|
||||||
|
this.id = id;
|
||||||
|
this.msg = msg;
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorTableException(int id) {
|
||||||
|
String message = SErrorCodeEerverConfig.errorTableMap.get(id);
|
||||||
|
if (StringUtil.isEmpty(message)){
|
||||||
|
this.id = -1;
|
||||||
|
this.msg = "操作失败,并未找到错误码:{"+id+"},请联系管理员";
|
||||||
|
}else {
|
||||||
|
this.id = id;
|
||||||
|
this.msg = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(List<String> params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return super.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getParams() {
|
||||||
|
return null == params ? new ArrayList<>() : params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "[CODE: " + this.getCode() + "][" + this.getMsg() + "][" +((super.getMessage()==null)?"":super.getMessage())+ "][" +((params!=null&& !params.isEmpty())?params.toString():"")+"] ";
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,13 +4,16 @@ import manager.STableManager;
|
||||||
import manager.Table;
|
import manager.Table;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Table(name ="ErrorCodeEerverConfig")
|
@Table(name ="ErrorCodeEerverConfig")
|
||||||
public class SErrorCodeEerverConfig implements BaseConfig {
|
public class SErrorCodeEerverConfig implements BaseConfig {
|
||||||
private static Map<String ,SErrorCodeEerverConfig> errorCodeMap;
|
private static Map<String ,SErrorCodeEerverConfig> errorCodeMap;
|
||||||
public static Map<Integer,SErrorCodeEerverConfig> errorMap;
|
public static Map<Integer,SErrorCodeEerverConfig> errorMap;
|
||||||
|
public static Map<Integer, String> errorTableMap = new HashMap<>();
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
@ -26,13 +29,15 @@ public class SErrorCodeEerverConfig implements BaseConfig {
|
||||||
Map<Integer, SErrorCodeEerverConfig> config = STableManager.getConfig(SErrorCodeEerverConfig.class);
|
Map<Integer, SErrorCodeEerverConfig> config = STableManager.getConfig(SErrorCodeEerverConfig.class);
|
||||||
Map<String ,SErrorCodeEerverConfig> errorCodeEerverConfigMap = new ConcurrentHashMap<>();
|
Map<String ,SErrorCodeEerverConfig> errorCodeEerverConfigMap = new ConcurrentHashMap<>();
|
||||||
Map<Integer,SErrorCodeEerverConfig> tempErrorMap = new ConcurrentHashMap<>();
|
Map<Integer,SErrorCodeEerverConfig> tempErrorMap = new ConcurrentHashMap<>();
|
||||||
for (Map.Entry<Integer, SErrorCodeEerverConfig> entry :config.entrySet()){
|
Map<Integer,String> tableErrorMap = new HashMap<>();
|
||||||
SErrorCodeEerverConfig sErrorCodeEerverConfig = entry.getValue();
|
for (SErrorCodeEerverConfig errorConfig : config.values()) {
|
||||||
errorCodeEerverConfigMap.put(sErrorCodeEerverConfig.getkey(),sErrorCodeEerverConfig);
|
errorCodeEerverConfigMap.put(errorConfig.getkey(),errorConfig);
|
||||||
tempErrorMap.put(sErrorCodeEerverConfig.getid(),sErrorCodeEerverConfig);
|
tempErrorMap.put(errorConfig.getid(),errorConfig);
|
||||||
|
tableErrorMap.put(errorConfig.getid(), errorConfig.getvalue());
|
||||||
}
|
}
|
||||||
errorCodeMap = errorCodeEerverConfigMap;
|
errorCodeMap = errorCodeEerverConfigMap;
|
||||||
errorMap = tempErrorMap;
|
errorMap = tempErrorMap;
|
||||||
|
errorTableMap = tableErrorMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue