类 ExceptionInterceptor

java.lang.Object
cn.hamm.airpower.exception.ExceptionInterceptor

@ControllerAdvice @ResponseStatus(OK) @ResponseBody public class ExceptionInterceptor extends Object

全局异常处理拦截器

作者:
Hamm
另请参阅:
  • 构造器详细资料

    • 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 @NotNull Exception exception)
      删除时的数据关联校验异常
    • notFoundHandle

      @ExceptionHandler(org.springframework.web.servlet.NoHandlerFoundException.class) public Json notFoundHandle(@NotNull @NotNull Exception exception)
      访问的接口没有实现
    • dataExceptionHandle

      @ExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException.class) public Json dataExceptionHandle(@NotNull @NotNull Exception 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 Exception exception)
      数据库连接发生错误
    • redisExceptionHandle

      @ExceptionHandler(org.springframework.data.redis.RedisConnectionFailureException.class) public Json redisExceptionHandle(@NotNull @NotNull Exception exception)
      REDIS连接发生错误
    • customExceptionHandle

      @ExceptionHandler(ResultException.class) public JsonData customExceptionHandle(@NotNull @NotNull ResultException result)
      自定义业务异常
    • jwtExceptionHandle

      @ExceptionHandler(cn.hutool.jwt.JWTException.class) public Json jwtExceptionHandle(@NotNull @NotNull Exception exception)
      JWT校验失败错误
    • 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 Exception exception)
      数据表或字段异常
    • otherExceptionHandle

      @ExceptionHandler({java.lang.Exception.class,java.lang.RuntimeException.class}) public Object otherExceptionHandle(@NotNull @NotNull Exception exception)
      其他异常