提交 31d907d8 authored 作者: 黄承天's avatar 黄承天

[通用模块]全局异常处理

上级 226e0fae
......@@ -32,20 +32,7 @@ import java.sql.SQLSyntaxErrorException;
public class GlobalExceptionHandler {
/**
* 业务错误
*
* @param e 报错信息
*/
@ResponseBody
@ExceptionHandler(ApiException.class)
public ResponseEntity errorMessage(ApiException e) {
log.warn("[自定义异常] {}", e.toString());
if (e.getResponseEntity() != null) {
return e.getResponseEntity();
}
return ResultUtil.failed(e.getMessage());
}
/**
......@@ -66,5 +53,27 @@ public class GlobalExceptionHandler {
log.warn(invalidFormatException.toString());
return ResultUtil.failed("列名不合法,请修改列名!");
}
/**
* 业务错误
*
* @param e 报错信息
*/
@ResponseBody
@ExceptionHandler(ApiException.class)
public ResponseEntity errorMessage(ApiException e) {
log.warn("[自定义异常] {}", e.toString());
if (e.getResponseEntity() != null) {
return e.getResponseEntity();
}
return ResultUtil.failed(e.getMessage());
}
@ExceptionHandler(Exception.class)
public ResponseEntity errorMessage(Exception e) {
e.printStackTrace();
return ResultUtil.failed(e.getMessage());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论