|
@@ -40,22 +40,6 @@ import static org.eco.vip.orm.exception.enums.GlobalErrorCode.NOT_FOUND;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class GlobalExceptionHandler {
|
|
public class GlobalExceptionHandler {
|
|
|
|
|
|
- public CommonResult<?> allExceptionHandler(HttpServletRequest request, Throwable throwable) {
|
|
|
|
- if (throwable instanceof MethodArgumentNotValidException) {
|
|
|
|
- return handleMethodArgumentNotValidException((MethodArgumentNotValidException) throwable);
|
|
|
|
- }
|
|
|
|
- if (throwable instanceof ConstraintViolationException) {
|
|
|
|
- return constraintViolationExceptionHandler((ConstraintViolationException) throwable);
|
|
|
|
- }
|
|
|
|
- if (throwable instanceof ValidationException) {
|
|
|
|
- return validationException((ValidationException) throwable);
|
|
|
|
- }
|
|
|
|
- if (throwable instanceof NoResourceFoundException) {
|
|
|
|
- return noResourceFoundExceptionHandler(request, (NoResourceFoundException) throwable);
|
|
|
|
- }
|
|
|
|
- return defaultExceptionHandler(request, throwable);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 业务异常
|
|
* 业务异常
|
|
*/
|
|
*/
|
|
@@ -127,16 +111,4 @@ public class GlobalExceptionHandler {
|
|
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", uri, loginException.getMessage());
|
|
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", uri, loginException.getMessage());
|
|
return CommonResult.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
|
return CommonResult.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 系统异常
|
|
|
|
- */
|
|
|
|
- @ExceptionHandler(Exception.class)
|
|
|
|
- public CommonResult<Void> defaultExceptionHandler(HttpServletRequest request, Throwable throwable) {
|
|
|
|
- log.warn("[defaultExceptionHandler]", throwable);
|
|
|
|
- String requestUri = request.getRequestURI();
|
|
|
|
- String message = ExceptionUtil.getRootCauseMessage(throwable);
|
|
|
|
- log.error("请求地址'{}',发生系统异常.{}", requestUri, message);
|
|
|
|
- return CommonResult.fail(message);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|