Commit 3b142e18 authored by yanzg's avatar yanzg

修改保存历史记录

parent 1826a3ad
......@@ -6,6 +6,7 @@ import com.yanzuoguang.util.vo.ResponseResult;
/**
* 异常处理帮助类
*
* @author 颜佐光
*/
public class ExceptionHelper {
......@@ -55,15 +56,33 @@ public class ExceptionHelper {
* @return 返回的数据
*/
public static ResponseResult getError(Exception e) {
return getError(e, false);
}
/**
* 根据异常获取返回数据
*
* @param e 异常信息
* @return 返回的数据
*/
public static ResponseResult getError(Exception e, boolean isFull) {
if (e instanceof CodeException) {
CodeException code = (CodeException) e;
return new ResponseResult(code.getCode(), code.getMessage(), null, code.getTarget());
return getError(code.getCode(), code.getMessage(), code.getTarget(), isFull);
} else {
String msg = e.getMessage();
if (StringHelper.isEmpty(msg)) {
msg = e.getClass().getName();
}
return ResponseResult.error(ResultConstants.UNKNOW_ERROR, msg, e);
return getError(ResultConstants.UNKNOW_ERROR, msg, e, isFull);
}
}
private static ResponseResult getError(String code, String msg, Object target, boolean isFull) {
if (isFull) {
return ResponseResult.error(code, msg);
} else {
return ResponseResult.error(code, msg, target);
}
}
}
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