Package com.unosquare.carmigo.exception
Class ExceptionResponseHandler
java.lang.Object
com.unosquare.carmigo.exception.ExceptionResponseHandler
Handles exceptions triggered throughout the application.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<ErrorResponse>
handleBadRequestException
(Exception exception) org.springframework.http.ResponseEntity<ErrorResponse>
handleBeanValidationException
(org.springframework.web.bind.MethodArgumentNotValidException methodArgumentNotValidException) Handles exception thrown byValid
in controllers which parses error messages.org.springframework.http.ResponseEntity<ErrorResponse>
handleConflictException
(Exception exception) org.springframework.http.ResponseEntity<ErrorResponse>
handleForbiddenException
(Exception exception) org.springframework.http.ResponseEntity<ErrorResponse>
handleNotFoundException
(Exception exception)
-
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 byValid
in controllers which parses error messages.- Parameters:
methodArgumentNotValidException
-MethodArgumentNotValidException
.- Returns:
- Response body as
ErrorResponse
.
-