Class ExceptionResponseHandler

java.lang.Object
com.unosquare.carmigo.exception.ExceptionResponseHandler

@ControllerAdvice public class ExceptionResponseHandler extends Object
Handles exceptions triggered throughout the application.
  • Constructor Details

    • ExceptionResponseHandler

      public ExceptionResponseHandler()
  • Method Details

    • handleNotFoundException

      @ExceptionHandler({org.springframework.dao.EmptyResultDataAccessException.class,jakarta.persistence.EntityNotFoundException.class,ResourceNotFoundException.class,jakarta.persistence.NoResultException.class,org.springframework.web.HttpRequestMethodNotSupportedException.class,org.springframework.dao.DataIntegrityViolationException.class}) public org.springframework.http.ResponseEntity<ErrorResponse> handleNotFoundException(Exception exception)
    • handleConflictException

      @ExceptionHandler({jakarta.persistence.EntityExistsException.class,java.lang.IllegalStateException.class}) public org.springframework.http.ResponseEntity<ErrorResponse> handleConflictException(Exception exception)
    • handleForbiddenException

      @ExceptionHandler({UnauthorizedException.class,ExpiredJwtException.class,org.springframework.security.authentication.BadCredentialsException.class}) public org.springframework.http.ResponseEntity<ErrorResponse> handleForbiddenException(Exception exception)
    • handleBadRequestException

      @ExceptionHandler({org.springframework.http.converter.HttpMessageNotReadableException.class,PatchException.class,org.springframework.validation.BindException.class}) public org.springframework.http.ResponseEntity<ErrorResponse> handleBadRequestException(Exception exception)
    • handleBeanValidationException

      @ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleBeanValidationException(org.springframework.web.bind.MethodArgumentNotValidException methodArgumentNotValidException)
      Handles exception thrown by Valid in controllers which parses error messages.
      Parameters:
      methodArgumentNotValidException - MethodArgumentNotValidException.
      Returns:
      Response body as ErrorResponse.