|
|
@@ -34,6 +34,7 @@ public class CustomExceptionHandler { |
|
|
|
@ExceptionHandler(BindException.class) |
|
|
|
@ResponseBody |
|
|
|
public JsonResult<Object> handleAuthenticationException(BindException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
BindingResult bindingResult = e.getBindingResult(); |
|
|
|
String errorMessage = ""; |
|
|
|
for (FieldError fieldError : bindingResult.getFieldErrors()) { |
|
|
@@ -48,6 +49,7 @@ public class CustomExceptionHandler { |
|
|
|
@ExceptionHandler(MethodArgumentNotValidException.class) |
|
|
|
@ResponseBody |
|
|
|
public JsonResult<Object> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.warn("系统参数校验异常,异常信息:{}", e.getMessage()); |
|
|
|
|
|
|
|
JsonResult<Object> error = JsonResult.error(SysExceptionEnum.PARAMETER_EMPTY_EXCEPTION.getCode(), |
|
|
@@ -73,6 +75,7 @@ public class CustomExceptionHandler { |
|
|
|
@ExceptionHandler(ServiceException.class) |
|
|
|
@ResponseBody |
|
|
|
public JsonResult<Object> handleServiceException(ServiceException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
// 打印业务异常日志 |
|
|
|
log.warn("系统业务逻辑异常,异常状态码 {},异常信息:{}", e.code, e.getMessage()); |
|
|
|
return JsonResult.error(e.code, e.getMessage()); |
|
|
@@ -98,6 +101,7 @@ public class CustomExceptionHandler { |
|
|
|
@ExceptionHandler(DataAccessException.class) |
|
|
|
@ResponseBody |
|
|
|
public JsonResult<Object> handleDataAccessException(DataAccessException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("系统数据访问异常,异常信息:{}", e.getMessage()); |
|
|
|
return JsonResult.error(SysExceptionEnum.DATAACCESS_EXCEPTION.getCode(), SysExceptionEnum.DATAACCESS_EXCEPTION.getMessage()); |
|
|
|
} |