Package net.hyshan.hou.core.app.handler
Class BaseExceptionHandler
java.lang.Object
net.hyshan.hou.core.app.handler.BaseExceptionHandler
全局异常拦截
- Author:
- zyw
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbindExceptionHandler(org.springframework.web.bind.MissingServletRequestParameterException e) handleGlobalException(org.springframework.web.bind.MethodArgumentNotValidException e) 拦截参数校验异常illegalArgumentExceptionHandler(jakarta.validation.ConstraintViolationException e) methodNotAllowedHandler(org.springframework.web.HttpRequestMethodNotSupportedException e) parameterBodyMissingExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException e) 缺少请求体异常处理器
-
Constructor Details
-
BaseExceptionHandler
public BaseExceptionHandler()
-
-
Method Details
-
handleGlobalException
@ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public R handleGlobalException(org.springframework.web.bind.MethodArgumentNotValidException e) 拦截参数校验异常- Parameters:
e-- Returns:
-
parameterBodyMissingExceptionHandler
@ResponseStatus(BAD_REQUEST) @ExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException.class) public R parameterBodyMissingExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException e) 缺少请求体异常处理器- Parameters:
e- 缺少请求体异常 使用get方式请求 而实体使用@RequestBody修饰
-
methodNotAllowedHandler
@ResponseStatus(METHOD_NOT_ALLOWED) @ExceptionHandler(org.springframework.web.HttpRequestMethodNotSupportedException.class) public R methodNotAllowedHandler(org.springframework.web.HttpRequestMethodNotSupportedException e) -
bindExceptionHandler
@ResponseStatus(BAD_REQUEST) @ExceptionHandler(org.springframework.web.bind.MissingServletRequestParameterException.class) public R bindExceptionHandler(org.springframework.web.bind.MissingServletRequestParameterException e) -
businessExceptionHandler
@ResponseStatus(OK) @ExceptionHandler(net.hyshan.hou.common.base.exception.BaseRtEx.class) public R businessExceptionHandler(BaseRtEx e) -
illegalArgumentExceptionHandler
@ResponseStatus(OK) @ExceptionHandler(jakarta.validation.ConstraintViolationException.class) public R illegalArgumentExceptionHandler(jakarta.validation.ConstraintViolationException e) -
runtimeExceptionHandler
@ResponseStatus(OK) @ExceptionHandler(java.lang.RuntimeException.class) public R runtimeExceptionHandler(RuntimeException e) -
throwableExceptionHandler
@ResponseStatus(INTERNAL_SERVER_ERROR) @ExceptionHandler(java.lang.Throwable.class) public R throwableExceptionHandler(Throwable e)
-