Class GlobalExceptionHandler

java.lang.Object
io.github.xezzon.zeroweb.common.exception.GlobalExceptionHandler

@RestControllerAdvice public class GlobalExceptionHandler extends Object
全局异常处理
Author:
xezzon
  • Constructor Details

    • GlobalExceptionHandler

      public GlobalExceptionHandler()
  • Method Details

    • handleException

      @ExceptionHandler(ZerowebBusinessException.class) public org.springframework.http.ResponseEntity<ErrorResult> handleException(ZerowebBusinessException e, jakarta.servlet.http.HttpServletRequest request)
      业务异常
    • handleException

      @ExceptionHandler(java.lang.Throwable.class) public org.springframework.http.ResponseEntity<ErrorResult> handleException(Throwable e, jakarta.servlet.http.HttpServletRequest request)
      非业务异常(通用)
    • handleException

      @ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public org.springframework.http.ResponseEntity<ErrorResult> handleException(org.springframework.web.bind.MethodArgumentNotValidException e, jakarta.servlet.http.HttpServletRequest request)
      参数校验不通过
    • handleException

      @ExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException.class) public org.springframework.http.ResponseEntity<ErrorResult> handleException(org.springframework.web.servlet.resource.NoResourceFoundException e, jakarta.servlet.http.HttpServletRequest request) throws org.springframework.web.servlet.resource.NoResourceFoundException
      请求资源不存在
      Throws:
      org.springframework.web.servlet.resource.NoResourceFoundException
    • handleException

      @ExceptionHandler(cn.dev33.satoken.exception.NotLoginException.class) public org.springframework.http.ResponseEntity<ErrorResult> handleException(cn.dev33.satoken.exception.NotLoginException e, jakarta.servlet.http.HttpServletRequest request)
      未登录
    • handleForbiddenException

      @ExceptionHandler({cn.dev33.satoken.exception.NotRoleException.class,cn.dev33.satoken.exception.NotPermissionException.class}) public org.springframework.http.ResponseEntity<ErrorResult> handleForbiddenException(RuntimeException e, jakarta.servlet.http.HttpServletRequest request)
      接口未授权
    • handleDataNotExistException

      @ExceptionHandler(jakarta.persistence.EntityNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResult> handleDataNotExistException(RuntimeException e, jakarta.servlet.http.HttpServletRequest request)
      数据已删除