@RestControllerAdvice public class DefaultExceptionHandler extends Object
| 构造器和说明 |
|---|
DefaultExceptionHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
ResponseInfo |
all(Exception e) |
ResponseInfo |
baseException(BaseException exception,
javax.servlet.http.HttpServletRequest request)
自定义异常的捕获
自定义抛出异常。
|
ResponseInfo |
bindException(org.springframework.boot.context.properties.bind.BindException e)
请求参数类型错误异常的捕获
|
ResponseInfo |
connect(ConnectException e)
网络连接失败!
|
ResponseInfo |
httpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException e) |
ResponseInfo |
methodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException e) |
ResponseInfo |
noHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException e)
404错误异常的捕获
|
ResponseInfo |
notAllowedMethod(org.springframework.web.HttpRequestMethodNotSupportedException e) |
ResponseInfo |
systemError(Exception e)
数据库操作出现异常
|
ResponseInfo |
uploadFile(org.springframework.web.multipart.MultipartException e)
文件上传错误异常的捕获
|
@ExceptionHandler(value=org.springframework.web.multipart.MultipartException.class) public ResponseInfo uploadFile(org.springframework.web.multipart.MultipartException e)
e - @ExceptionHandler(value=org.springframework.http.converter.HttpMessageNotReadableException.class) public ResponseInfo httpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException e)
@ExceptionHandler(value=org.springframework.boot.context.properties.bind.BindException.class) public ResponseInfo bindException(org.springframework.boot.context.properties.bind.BindException e)
e - @ExceptionHandler(value=org.springframework.web.bind.MethodArgumentNotValidException.class) public ResponseInfo methodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException e)
@ExceptionHandler(value=org.springframework.web.servlet.NoHandlerFoundException.class) public ResponseInfo noHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException e)
e - @ExceptionHandler(value=BaseException.class) public ResponseInfo baseException(BaseException exception, javax.servlet.http.HttpServletRequest request)
exception - request - @ExceptionHandler(value={java.sql.SQLException.class,org.springframework.dao.DataAccessException.class})
public ResponseInfo systemError(Exception e)
e - @ExceptionHandler(value=java.net.ConnectException.class) public ResponseInfo connect(ConnectException e)
e - @ExceptionHandler(value=java.lang.Exception.class) public ResponseInfo all(Exception e)
@ExceptionHandler(value=org.springframework.web.HttpRequestMethodNotSupportedException.class) public ResponseInfo notAllowedMethod(org.springframework.web.HttpRequestMethodNotSupportedException e)
Copyright © 2021. All rights reserved.