Class GlobalExceptionHandler

java.lang.Object
com.dmasone.identity.infrastructure.exception.GlobalExceptionHandler

@RestControllerAdvice public class GlobalExceptionHandler extends Object
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 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 errors extension
    • 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