Class GlobalExceptionHandler
java.lang.Object
tech.riemann.nif.starter.exception.GlobalExceptionHandler
全局异常处理器
- Author:
- Kerbores(kerbores@riemann.tech)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthentication(tech.riemann.nif.auth.AuthenticationException e, jakarta.servlet.http.HttpServletRequest request) authorization(tech.riemann.nif.auth.AuthorizationException e, jakarta.servlet.http.HttpServletRequest request) bizExceptionHandler(BizException e, jakarta.servlet.http.HttpServletRequest request) defaultErrorHandler(@NonNull Exception e, jakarta.servlet.http.HttpServletRequest request) fileValidation(FileValidationException e, jakarta.servlet.http.HttpServletRequest request) handle(jakarta.validation.ValidationException e, jakarta.servlet.http.HttpServletRequest request) handleJsonParseError(org.springframework.http.converter.HttpMessageNotReadableException e, jakarta.servlet.http.HttpServletRequest request) handleMaxUploadSize(org.springframework.web.multipart.MaxUploadSizeExceededException e, jakarta.servlet.http.HttpServletRequest request) handleMethodNotAllowed(org.springframework.web.HttpRequestMethodNotSupportedException e, jakarta.servlet.http.HttpServletRequest request) handleMissingParameter(org.springframework.web.bind.MissingServletRequestParameterException e, jakarta.servlet.http.HttpServletRequest request) handleTypeMismatch(Exception e, jakarta.servlet.http.HttpServletRequest request) noResourceFoundExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException e, jakarta.servlet.http.HttpServletRequest request) validate(org.springframework.web.bind.MethodArgumentNotValidException e, jakarta.servlet.http.HttpServletRequest request)
-
Constructor Details
-
GlobalExceptionHandler
public GlobalExceptionHandler()
-
-
Method Details
-
bizExceptionHandler
@ExceptionHandler(BizException.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public GlobalError bizExceptionHandler(BizException e, jakarta.servlet.http.HttpServletRequest request) -
fileValidation
@ExceptionHandler(FileValidationException.class) @ResponseStatus(BAD_REQUEST) public GlobalError fileValidation(FileValidationException e, jakarta.servlet.http.HttpServletRequest request) -
handle
@ExceptionHandler(jakarta.validation.ValidationException.class) @ResponseStatus(BAD_REQUEST) public GlobalError handle(jakarta.validation.ValidationException e, jakarta.servlet.http.HttpServletRequest request) -
validate
@ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) @ResponseStatus(BAD_REQUEST) public GlobalError validate(org.springframework.web.bind.MethodArgumentNotValidException e, jakarta.servlet.http.HttpServletRequest request) -
handleJsonParseError
@ExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException.class) @ResponseStatus(BAD_REQUEST) public GlobalError handleJsonParseError(org.springframework.http.converter.HttpMessageNotReadableException e, jakarta.servlet.http.HttpServletRequest request) -
handleTypeMismatch
@ExceptionHandler({org.springframework.beans.TypeMismatchException.class,org.springframework.web.method.annotation.MethodArgumentTypeMismatchException.class}) @ResponseStatus(BAD_REQUEST) public GlobalError handleTypeMismatch(Exception e, jakarta.servlet.http.HttpServletRequest request) -
handleMissingParameter
@ExceptionHandler(org.springframework.web.bind.MissingServletRequestParameterException.class) @ResponseStatus(BAD_REQUEST) public GlobalError handleMissingParameter(org.springframework.web.bind.MissingServletRequestParameterException e, jakarta.servlet.http.HttpServletRequest request) -
handleMethodNotAllowed
@ExceptionHandler(org.springframework.web.HttpRequestMethodNotSupportedException.class) @ResponseStatus(METHOD_NOT_ALLOWED) public GlobalError handleMethodNotAllowed(org.springframework.web.HttpRequestMethodNotSupportedException e, jakarta.servlet.http.HttpServletRequest request) -
handleMaxUploadSize
@ExceptionHandler(org.springframework.web.multipart.MaxUploadSizeExceededException.class) @ResponseStatus(CONTENT_TOO_LARGE) public GlobalError handleMaxUploadSize(org.springframework.web.multipart.MaxUploadSizeExceededException e, jakarta.servlet.http.HttpServletRequest request) -
authentication
@ExceptionHandler(tech.riemann.nif.auth.AuthenticationException.class) @ResponseStatus(UNAUTHORIZED) public GlobalError authentication(tech.riemann.nif.auth.AuthenticationException e, jakarta.servlet.http.HttpServletRequest request) -
authorization
@ExceptionHandler(tech.riemann.nif.auth.AuthorizationException.class) @ResponseStatus(FORBIDDEN) public GlobalError authorization(tech.riemann.nif.auth.AuthorizationException e, jakarta.servlet.http.HttpServletRequest request) -
noResourceFoundExceptionHandler
@ExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException.class) @ResponseStatus(NOT_FOUND) public GlobalError noResourceFoundExceptionHandler(org.springframework.web.servlet.resource.NoResourceFoundException e, jakarta.servlet.http.HttpServletRequest request) -
defaultErrorHandler
@ExceptionHandler(Exception.class) @ResponseStatus(INTERNAL_SERVER_ERROR) public GlobalError defaultErrorHandler(@NonNull Exception e, jakarta.servlet.http.HttpServletRequest request)
-