类 GlobalExceptionHandler

java.lang.Object
io.github.lishangbu.orange.web.exception.GlobalExceptionHandler

@RestControllerAdvice @Order(2147483646) public class GlobalExceptionHandler extends Object
从以下版本开始:
2018/8/30 全局异常处理器
作者:
lishangbu
  • 构造器详细资料

    • GlobalExceptionHandler

      public GlobalExceptionHandler()
  • 方法详细资料

    • handleGlobalException

      @ExceptionHandler(Exception.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public ApiResult<Void> handleGlobalException(Exception e)
      全局异常.
      参数:
      e - the e
      返回:
      ResultBean
    • handleRuntimeException

      @ExceptionHandler(RuntimeException.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public ApiResult<Void> handleRuntimeException(RuntimeException e)
      运行时异常.
      参数:
      e - the e
      返回:
      ResultBean
    • handleHttpMessageNotWritableException

      @ExceptionHandler(org.springframework.http.converter.HttpMessageNotWritableException.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public ApiResult<Void> handleHttpMessageNotWritableException(org.springframework.http.converter.HttpMessageNotWritableException e)
      运行时异常.
      参数:
      e - the e
      返回:
      ResultBean
    • handleBodyValidException

      @ExceptionHandler({org.springframework.web.bind.MethodArgumentNotValidException.class,org.springframework.validation.BindException.class}) @ResponseStatus(BAD_REQUEST) public ApiResult<Void> handleBodyValidException(org.springframework.web.bind.MethodArgumentNotValidException exception)
      BindException
      参数:
      exception - 参数绑定错误
      返回:
      ResultBean
    • handleIllegalArgumentException

      @ExceptionHandler(IllegalArgumentException.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public ApiResult<Void> handleIllegalArgumentException(IllegalArgumentException exception)
      处理业务校验过程中碰到的非法参数异常 该异常基本由Assert抛出
      参数:
      exception - 参数校验异常
      返回:
      API返回结果对象包装后的错误输出结果
      另请参阅:
      • Assert.hasLength(String, String)
      • Assert.hasText(String, String)
      • Assert.isTrue(boolean, String)
      • Assert.isNull(Object, String)
      • Assert.notNull(Object, String)
    • handleIllegalStateException

      @ExceptionHandler(IllegalStateException.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public ApiResult<Void> handleIllegalStateException(IllegalStateException exception)
      处理非法状态
      参数:
      exception -
      返回:
    • handleSQLException

      @ExceptionHandler(SQLException.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public ApiResult<Void> handleSQLException(SQLException exception)
      处理SQL异常
      参数:
      exception -
      返回:
    • handleUnsupportedOperationException

      @ExceptionHandler(UnsupportedOperationException.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public ApiResult<Void> handleUnsupportedOperationException(UnsupportedOperationException exception)
      不支持的操作类型
      参数:
      exception -
      返回:
    • handleNoResourceFoundException

      @ExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException.class) @ResponseStatus(NOT_FOUND) public ApiResult<Void> handleNoResourceFoundException(org.springframework.web.servlet.resource.NoResourceFoundException exception)
      处理资源不存在
      参数:
      exception - 资源不存在异常
      返回:
    • handleHttpRequestMethodNotSupportedExceptionn

      @ExceptionHandler(org.springframework.web.HttpRequestMethodNotSupportedException.class) @ResponseStatus(METHOD_NOT_ALLOWED) public ApiResult<Void> handleHttpRequestMethodNotSupportedExceptionn(org.springframework.web.HttpRequestMethodNotSupportedException exception)