Class GlobalExceptionHandler
java.lang.Object
com.dmasone.identity.infrastructure.exception.GlobalExceptionHandler
Converts application and validation exceptions into RFC 7807 Problem Details.
Centralizing exception translation keeps controllers focused on HTTP orchestration and gives API consumers consistent error payloads across versions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ProblemDetailConverts duplicate-email failures into HTTP 409 responses.org.springframework.http.ProblemDetailhandleTypeMismatch(org.springframework.web.method.annotation.MethodArgumentTypeMismatchException ex) Converts invalid path parameters, such as malformed UUIDs, into HTTP 400 responses.org.springframework.http.ProblemDetailConverts missing-user failures into HTTP 404 responses.org.springframework.http.ProblemDetailhandleValidation(org.springframework.web.bind.MethodArgumentNotValidException ex) Converts bean validation errors into HTTP 400 responses with field details.
-
Constructor Details
-
GlobalExceptionHandler
public GlobalExceptionHandler()
-
-
Method Details
-
handleEmailExists
@ExceptionHandler(EmailAlreadyExistsException.class) public org.springframework.http.ProblemDetail handleEmailExists(EmailAlreadyExistsException ex) Converts duplicate-email failures into HTTP 409 responses.- Parameters:
ex- duplicate email exception- Returns:
- problem detail payload for the API response
-
handleUserNotFound
@ExceptionHandler(UserNotFoundException.class) public org.springframework.http.ProblemDetail handleUserNotFound(UserNotFoundException ex) Converts missing-user failures into HTTP 404 responses.- Parameters:
ex- missing user exception- Returns:
- problem detail payload for the API response
-
handleValidation
@ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public org.springframework.http.ProblemDetail handleValidation(org.springframework.web.bind.MethodArgumentNotValidException ex) Converts bean validation errors into HTTP 400 responses with field details.- Parameters:
ex- validation exception raised by Spring MVC- Returns:
- problem detail payload with an
errorsextension
-
handleTypeMismatch
@ExceptionHandler(org.springframework.web.method.annotation.MethodArgumentTypeMismatchException.class) public org.springframework.http.ProblemDetail handleTypeMismatch(org.springframework.web.method.annotation.MethodArgumentTypeMismatchException ex) Converts invalid path parameters, such as malformed UUIDs, into HTTP 400 responses.- Parameters:
ex- type mismatch raised by Spring MVC- Returns:
- problem detail payload for the API response
-