Class GlobalExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.order.api01authgateway.exception.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
Centralized exception handling component using
RestControllerAdvice.
Maps application-specific exceptions to ProblemDetail objects compliant with
RFC 7807 (Problem Details for HTTP APIs).
-
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 TypeMethodDescriptionorg.springframework.http.ProblemDetailhandleAuthenticationException(org.springframework.security.core.AuthenticationException ex) Handles generalAuthenticationExceptionand maps it to a 401 Unauthorized response.org.springframework.http.ProblemDetailhandleBadCredentials(org.springframework.security.authentication.BadCredentialsException ex) HandlesBadCredentialsExceptionand maps it to a 401 Unauthorized response.org.springframework.http.ProblemDetailHandles unexpectedExceptionoccurrences and maps them to a 500 Internal Server Error response.Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
createProblemDetail, createResponseEntity, getMessageSource, handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleErrorResponseException, handleException, handleExceptionInternal, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMaxUploadSizeExceededException, handleMethodArgumentNotValid, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource
-
Constructor Details
-
GlobalExceptionHandler
public GlobalExceptionHandler()
-
-
Method Details
-
handleBadCredentials
@ExceptionHandler(org.springframework.security.authentication.BadCredentialsException.class) public org.springframework.http.ProblemDetail handleBadCredentials(org.springframework.security.authentication.BadCredentialsException ex) HandlesBadCredentialsExceptionand maps it to a 401 Unauthorized response.- Parameters:
ex- The exception encountered.- Returns:
- A
ProblemDetaildescribing the error.
-
handleAuthenticationException
@ExceptionHandler(org.springframework.security.core.AuthenticationException.class) public org.springframework.http.ProblemDetail handleAuthenticationException(org.springframework.security.core.AuthenticationException ex) Handles generalAuthenticationExceptionand maps it to a 401 Unauthorized response.- Parameters:
ex- The exception encountered.- Returns:
- A
ProblemDetaildescribing the error.
-
handleGeneralException
@ExceptionHandler(java.lang.Exception.class) public org.springframework.http.ProblemDetail handleGeneralException(Exception ex) Handles unexpectedExceptionoccurrences and maps them to a 500 Internal Server Error response.- Parameters:
ex- The exception encountered.- Returns:
- A
ProblemDetaildescribing the error.
-