@RestControllerAdvice public class ExceptionAdvice extends Object
Constructor and Description |
---|
ExceptionAdvice() |
Modifier and Type | Method and Description |
---|---|
ResponseBean |
globalException(javax.servlet.http.HttpServletRequest request,
Throwable ex)
捕捉其他所有异常
|
ResponseBean |
handle(CustomException e)
捕捉其他所有自定义异常
|
ResponseBean |
handle(org.springframework.web.servlet.NoHandlerFoundException e)
捕捉404异常
|
ResponseBean |
handle401(CustomUnauthorizedException e)
捕捉UnauthorizedException自定义异常
|
ResponseBean |
handle401(org.apache.shiro.ShiroException e)
捕捉所有Shiro异常
|
ResponseBean |
handle401(org.apache.shiro.authz.UnauthenticatedException e)
单独捕捉Shiro(UnauthenticatedException)异常
该异常为以游客身份访问有权限管控的请求无法对匿名主体进行授权,而授权失败所抛出的异常
|
ResponseBean |
handle401(org.apache.shiro.authz.UnauthorizedException e)
单独捕捉Shiro(UnauthorizedException)异常
该异常为访问有权限管控的请求而该用户没有所需权限所抛出的异常
|
ResponseBean |
validException(org.springframework.validation.BindException e)
捕捉校验异常(BindException)
|
ResponseBean |
validException(org.springframework.web.bind.MethodArgumentNotValidException e)
捕捉校验异常(MethodArgumentNotValidException)
|
@ResponseStatus(value=UNAUTHORIZED) @ExceptionHandler(value=org.apache.shiro.ShiroException.class) public ResponseBean handle401(org.apache.shiro.ShiroException e)
e
- @ResponseStatus(value=UNAUTHORIZED) @ExceptionHandler(value=org.apache.shiro.authz.UnauthorizedException.class) public ResponseBean handle401(org.apache.shiro.authz.UnauthorizedException e)
e
- @ResponseStatus(value=UNAUTHORIZED) @ExceptionHandler(value=org.apache.shiro.authz.UnauthenticatedException.class) public ResponseBean handle401(org.apache.shiro.authz.UnauthenticatedException e)
e
- @ResponseStatus(value=UNAUTHORIZED) @ExceptionHandler(value=CustomUnauthorizedException.class) public ResponseBean handle401(CustomUnauthorizedException e)
@ResponseStatus(value=BAD_REQUEST) @ExceptionHandler(value=org.springframework.validation.BindException.class) public ResponseBean validException(org.springframework.validation.BindException e)
@ResponseStatus(value=BAD_REQUEST) @ExceptionHandler(value=org.springframework.web.bind.MethodArgumentNotValidException.class) public ResponseBean validException(org.springframework.web.bind.MethodArgumentNotValidException e)
@ResponseStatus(value=BAD_REQUEST) @ExceptionHandler(value=CustomException.class) public ResponseBean handle(CustomException e)
@ResponseStatus(value=NOT_FOUND) @ExceptionHandler(value=org.springframework.web.servlet.NoHandlerFoundException.class) public ResponseBean handle(org.springframework.web.servlet.NoHandlerFoundException e)
@ResponseStatus(value=INTERNAL_SERVER_ERROR) @ExceptionHandler(value=java.lang.Exception.class) public ResponseBean globalException(javax.servlet.http.HttpServletRequest request, Throwable ex)
request
- ex
- Copyright © 2020 Pivotal Software, Inc.. All rights reserved.