Class GlobalExceptionHandler
java.lang.Object
io.github.xezzon.zeroweb.common.exception.GlobalExceptionHandler
全局异常处理
- Author:
- xezzon
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<ErrorResult>
handleDataNotExistException
(RuntimeException e, jakarta.servlet.http.HttpServletRequest request) 数据已删除org.springframework.http.ResponseEntity<ErrorResult>
handleException
(cn.dev33.satoken.exception.NotLoginException e, jakarta.servlet.http.HttpServletRequest request) 未登录org.springframework.http.ResponseEntity<ErrorResult>
handleException
(ZerowebBusinessException e, jakarta.servlet.http.HttpServletRequest request) 业务异常org.springframework.http.ResponseEntity<ErrorResult>
handleException
(Throwable e, jakarta.servlet.http.HttpServletRequest request) 非业务异常(通用)org.springframework.http.ResponseEntity<ErrorResult>
handleException
(org.springframework.web.bind.MethodArgumentNotValidException e, jakarta.servlet.http.HttpServletRequest request) 参数校验不通过org.springframework.http.ResponseEntity<ErrorResult>
handleException
(org.springframework.web.servlet.resource.NoResourceFoundException e, jakarta.servlet.http.HttpServletRequest request) 请求资源不存在org.springframework.http.ResponseEntity<ErrorResult>
handleForbiddenException
(RuntimeException e, jakarta.servlet.http.HttpServletRequest request) 接口未授权
-
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) 数据已删除
-