类 ExceptionInterceptor
java.lang.Object
cn.hamm.airpower.interceptor.ExceptionInterceptor
@ControllerAdvice
@ResponseStatus(OK)
@ResponseBody
public class ExceptionInterceptor
extends Object
全局异常处理拦截器
- 作者:
- Hamm.cn
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明badRequestHandle(@NotNull jakarta.validation.ConstraintViolationException exception) 参数校验失败badRequestHandle(@NotNull org.springframework.web.bind.MethodArgumentNotValidException exception) 参数验证失败databaseExceptionHandle(@NotNull org.springframework.transaction.CannotCreateTransactionException exception) 数据库连接发生错误dataExceptionHandle(@NotNull org.springframework.http.converter.HttpMessageNotReadableException exception) 请求的数据不是标准JSONdeleteUsingDataException(Exception exception) 删除时的数据关联校验异常httpMediaTypeNotSupportedExceptionHandle(@NotNull org.springframework.web.HttpMediaTypeNotSupportedException exception) 不支持的数据类型invalidDataAccessResourceUsageExceptionHandle(@NotNull org.springframework.dao.InvalidDataAccessResourceUsageException exception) 数据表或字段异常maxUploadSizeExceededExceptionHandle(@NotNull org.springframework.web.multipart.MaxUploadSizeExceededException exception) 数据表或字段异常methodExceptionHandle(@NotNull org.springframework.web.HttpRequestMethodNotSupportedException exception) 不支持的请求方法notFoundHandle(@NotNull org.springframework.web.servlet.NoHandlerFoundException exception, jakarta.servlet.http.HttpServletResponse response) 访问的接口没有实现otherExceptionHandle(Exception exception) 其他异常propertyReferenceExceptionHandle(@NotNull org.springframework.data.mapping.PropertyReferenceException exception) 数据字段不存在redisExceptionHandle(@NotNull org.springframework.data.redis.RedisConnectionFailureException exception) REDIS连接发生错误systemExceptionHandle(@NotNull ServiceException exception) 系统自定义异常
-
构造器详细资料
-
ExceptionInterceptor
public ExceptionInterceptor()
-
-
方法详细资料
-
badRequestHandle
@ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public Json badRequestHandle(@NotNull @NotNull org.springframework.web.bind.MethodArgumentNotValidException exception) 参数验证失败
-
badRequestHandle
@ExceptionHandler(jakarta.validation.ConstraintViolationException.class) public Json badRequestHandle(@NotNull @NotNull jakarta.validation.ConstraintViolationException exception) 参数校验失败
-
deleteUsingDataException
@ExceptionHandler({java.sql.SQLIntegrityConstraintViolationException.class,org.springframework.dao.DataIntegrityViolationException.class}) public Json deleteUsingDataException(@NotNull Exception exception) 删除时的数据关联校验异常
-
notFoundHandle
@ExceptionHandler(org.springframework.web.servlet.NoHandlerFoundException.class) public Json notFoundHandle(@NotNull @NotNull org.springframework.web.servlet.NoHandlerFoundException exception, jakarta.servlet.http.HttpServletResponse response) 访问的接口没有实现
-
dataExceptionHandle
@ExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException.class) public Json dataExceptionHandle(@NotNull @NotNull org.springframework.http.converter.HttpMessageNotReadableException exception) 请求的数据不是标准JSON
-
methodExceptionHandle
@ExceptionHandler(org.springframework.web.HttpRequestMethodNotSupportedException.class) public Json methodExceptionHandle(@NotNull @NotNull org.springframework.web.HttpRequestMethodNotSupportedException exception) 不支持的请求方法
-
httpMediaTypeNotSupportedExceptionHandle
@ExceptionHandler(org.springframework.web.HttpMediaTypeNotSupportedException.class) public Json httpMediaTypeNotSupportedExceptionHandle(@NotNull @NotNull org.springframework.web.HttpMediaTypeNotSupportedException exception) 不支持的数据类型
-
databaseExceptionHandle
@ExceptionHandler(org.springframework.transaction.CannotCreateTransactionException.class) public Json databaseExceptionHandle(@NotNull @NotNull org.springframework.transaction.CannotCreateTransactionException exception) 数据库连接发生错误
-
redisExceptionHandle
@ExceptionHandler(org.springframework.data.redis.RedisConnectionFailureException.class) public Json redisExceptionHandle(@NotNull @NotNull org.springframework.data.redis.RedisConnectionFailureException exception) REDIS连接发生错误
-
systemExceptionHandle
@ExceptionHandler(ServiceException.class) public Json systemExceptionHandle(@NotNull @NotNull ServiceException exception) 系统自定义异常
-
propertyReferenceExceptionHandle
@ExceptionHandler(org.springframework.data.mapping.PropertyReferenceException.class) public Json propertyReferenceExceptionHandle(@NotNull @NotNull org.springframework.data.mapping.PropertyReferenceException exception) 数据字段不存在
-
invalidDataAccessResourceUsageExceptionHandle
@ExceptionHandler(org.springframework.dao.InvalidDataAccessResourceUsageException.class) public Json invalidDataAccessResourceUsageExceptionHandle(@NotNull @NotNull org.springframework.dao.InvalidDataAccessResourceUsageException exception) 数据表或字段异常
-
maxUploadSizeExceededExceptionHandle
@ExceptionHandler(org.springframework.web.multipart.MaxUploadSizeExceededException.class) public Json maxUploadSizeExceededExceptionHandle(@NotNull @NotNull org.springframework.web.multipart.MaxUploadSizeExceededException exception) 数据表或字段异常
-
otherExceptionHandle
@ExceptionHandler({java.lang.Exception.class,java.lang.RuntimeException.class}) public Object otherExceptionHandle(@NotNull Exception exception) 其他异常
-