Package com.github.can019.global.handler
Class GlobalExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.github.can019.global.handler.GlobalExceptionHandler
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.MessageSourceAware
@RestControllerAdvice
public class GlobalExceptionHandler
extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
Application에서 발생하는 모든 exception을 처리하는 handler.
- Since:
- 0.0.3
-
Field Summary
Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.http.ResponseEntity
<Object> handleExceptionInternal
(Exception ex, Object body, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode statusCode, org.springframework.web.context.request.WebRequest request) 응답 body 구성에 필요한 데이터 전처리를 진행.org.springframework.http.ResponseEntity
handleRuntimeException
(RuntimeException ex, org.springframework.web.context.request.WebRequest webRequest) Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
createProblemDetail, createResponseEntity, getMessageSource, handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleErrorResponseException, handleException, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMaxUploadSizeExceededException, handleMethodArgumentNotValid, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource
-
Constructor Details
-
GlobalExceptionHandler
public GlobalExceptionHandler()
-
-
Method Details
-
handleRuntimeException
@ExceptionHandler(java.lang.RuntimeException.class) public org.springframework.http.ResponseEntity handleRuntimeException(RuntimeException ex, org.springframework.web.context.request.WebRequest webRequest) -
handleExceptionInternal
protected org.springframework.http.ResponseEntity<Object> handleExceptionInternal(Exception ex, @Nullable Object body, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode statusCode, org.springframework.web.context.request.WebRequest request) 응답 body 구성에 필요한 데이터 전처리를 진행.응답 body가 null이라면 ErrorResponse 객체를 가져와 body를 구성
- Overrides:
handleExceptionInternal
in classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
- Parameters:
ex
- causebody
- body controller에서 작성한 bodyheaders
-statusCode
- controller에서 처리한 statusCoderequest
-- Returns:
- See Also:
-