Class ProblemDetailsExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
at.jku.dke.etutor.task_app.controllers.ProblemDetailsExceptionHandler
- All Implemented Interfaces:
Aware
,MessageSourceAware
@RestControllerAdvice
public class ProblemDetailsExceptionHandler
extends ResponseEntityExceptionHandler
Controller advice for handling exceptions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
The base URL for problem details types.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 TypeMethodDescriptionhandleAccessDeniedException
(org.springframework.security.access.AccessDeniedException ex, WebRequest request) Handle exceptions of typeAccessDeniedException
.handleBadCredentialsException
(org.springframework.security.authentication.BadCredentialsException ex, WebRequest request) Handle exceptions of typeBadCredentialsException
.Handle exceptions of typeConstraintViolationException
.handleConstraintViolationException
(org.hibernate.exception.ConstraintViolationException ex, WebRequest request) Handle exceptions of typeConstraintViolationException
.Handle exceptions of typeDataIntegrityViolationException
.handleDuplicateKeyException
(DuplicateKeyException ex, WebRequest request) Handle exceptions of typeDuplicateKeyException
.handleEntityNotFoundException
(jakarta.persistence.EntityNotFoundException ex, WebRequest request) Handle exceptions of typeEntityNotFoundException
.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
-
Field Details
-
BASE_URL
The base URL for problem details types.- See Also:
-
-
Constructor Details
-
ProblemDetailsExceptionHandler
public ProblemDetailsExceptionHandler()Creates a new instance of classProblemDetailsExceptionHandler
.
-
-
Method Details
-
handleBadCredentialsException
@ExceptionHandler(org.springframework.security.authentication.BadCredentialsException.class) public ResponseEntity<Object> handleBadCredentialsException(org.springframework.security.authentication.BadCredentialsException ex, WebRequest request) Handle exceptions of typeBadCredentialsException
.- Parameters:
ex
- The exception to handle.request
- The current request.- Returns:
- The response entity.
-
handleAccessDeniedException
@ExceptionHandler(org.springframework.security.access.AccessDeniedException.class) public ResponseEntity<Object> handleAccessDeniedException(org.springframework.security.access.AccessDeniedException ex, WebRequest request) Handle exceptions of typeAccessDeniedException
.- Parameters:
ex
- The exception to handle.request
- The current request.- Returns:
- The response entity.
-
handleEntityNotFoundException
@ExceptionHandler(jakarta.persistence.EntityNotFoundException.class) public ResponseEntity<Object> handleEntityNotFoundException(jakarta.persistence.EntityNotFoundException ex, WebRequest request) Handle exceptions of typeEntityNotFoundException
.- Parameters:
ex
- The exception to handle.request
- The current request.- Returns:
- The response entity.
-
handleConstraintViolationException
@ExceptionHandler(jakarta.validation.ConstraintViolationException.class) public ResponseEntity<Object> handleConstraintViolationException(ConstraintViolationException ex, WebRequest request) Handle exceptions of typeConstraintViolationException
.- Parameters:
ex
- The exception to handle.request
- The current request.- Returns:
- The response entity.
-
handleConstraintViolationException
@ExceptionHandler(org.hibernate.exception.ConstraintViolationException.class) public ResponseEntity<Object> handleConstraintViolationException(org.hibernate.exception.ConstraintViolationException ex, WebRequest request) Handle exceptions of typeConstraintViolationException
.- Parameters:
ex
- The exception to handle.request
- The current request.- Returns:
- The response entity.
-
handleDuplicateKeyException
@ExceptionHandler(org.springframework.dao.DuplicateKeyException.class) public ResponseEntity<Object> handleDuplicateKeyException(DuplicateKeyException ex, WebRequest request) Handle exceptions of typeDuplicateKeyException
.- Parameters:
ex
- The exception to handle.request
- The current request.- Returns:
- The response entity.
-
handleDataIntegrityViolationException
@ExceptionHandler(org.springframework.dao.DataIntegrityViolationException.class) public ResponseEntity<Object> handleDataIntegrityViolationException(DataIntegrityViolationException ex, WebRequest request) Handle exceptions of typeDataIntegrityViolationException
.- Parameters:
ex
- The exception to handle.request
- The current request.- Returns:
- The response entity.
-