Package no.nsd.qddt.utils.advice
Class ControllerExceptionAdvice
- java.lang.Object
-
- no.nsd.qddt.utils.advice.ControllerExceptionAdvice
-
@ControllerAdvice @RequestMapping(value="/error", produces="application/json") public class ControllerExceptionAdvice extends java.lang.Object
Controller-advice to handle exception casted by any requests coming from controllers. This will not interfere with the service layer, but it shares the exceptions that can be cast from the service layer.
-
-
Constructor Summary
Constructors Constructor Description ControllerExceptionAdvice()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ControllerAdviceExceptionMessage
defaultErrorHandler(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Default exception handler.ControllerAdviceExceptionMessage
handleAccessDeniedException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeAccessDeniedException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleConcurencyCheckedFailed(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeOptimisticLockingFailureException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleDeniedAuthorization(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeUserDeniedAuthorizationException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleDescendantsArchivedException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeDescendantsArchivedException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleInvalidPasswordException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeInvalidPasswordException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleRefInUseFailure(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeOptimisticLockingFailureException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleResourceNotFound(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeResourceNotFoundException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleRetrievalFailure(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeOptimisticLockingFailureException
when they occur from methods executed from the controller.ControllerAdviceExceptionMessage
handleUserByEmailNotFound(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeUserNotFoundException
when they occur from methods executed from the controller.
-
-
-
Method Detail
-
handleResourceNotFound
@ResponseStatus(NOT_FOUND) @ExceptionHandler(ResourceNotFoundException.class) @ResponseBody public ControllerAdviceExceptionMessage handleResourceNotFound(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeResourceNotFoundException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
ControllerAdviceExceptionMessage
object
-
handleUserByEmailNotFound
@ResponseStatus(NOT_FOUND) @ExceptionHandler(UserNotFoundException.class) @ResponseBody public ControllerAdviceExceptionMessage handleUserByEmailNotFound(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeUserNotFoundException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
ControllerAdviceExceptionMessage
object
-
handleDeniedAuthorization
@ResponseStatus(NOT_MODIFIED) @ExceptionHandler(org.springframework.security.oauth2.common.exceptions.UserDeniedAuthorizationException.class) @ResponseBody public ControllerAdviceExceptionMessage handleDeniedAuthorization(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeUserDeniedAuthorizationException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
ControllerAdviceExceptionMessage
object
-
handleConcurencyCheckedFailed
@ResponseStatus(CONFLICT) @ExceptionHandler(org.springframework.orm.ObjectOptimisticLockingFailureException.class) @ResponseBody public ControllerAdviceExceptionMessage handleConcurencyCheckedFailed(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeOptimisticLockingFailureException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
ControllerAdviceExceptionMessage
object
-
handleRetrievalFailure
@ResponseStatus(CONFLICT) @ExceptionHandler(org.springframework.orm.jpa.JpaObjectRetrievalFailureException.class) @ResponseBody public ControllerAdviceExceptionMessage handleRetrievalFailure(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeOptimisticLockingFailureException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
ControllerAdviceExceptionMessage
object
-
handleRefInUseFailure
@ResponseStatus(CONFLICT) @ExceptionHandler(ReferenceInUseException.class) @ResponseBody public ControllerAdviceExceptionMessage handleRefInUseFailure(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeOptimisticLockingFailureException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
ControllerAdviceExceptionMessage
object
-
handleAccessDeniedException
@ResponseStatus(METHOD_NOT_ALLOWED) @ExceptionHandler(org.springframework.security.access.AccessDeniedException.class) @ResponseBody public ControllerAdviceExceptionMessage handleAccessDeniedException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeAccessDeniedException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
AccessDeniedException
object
-
handleInvalidPasswordException
@ResponseStatus(INTERNAL_SERVER_ERROR) @ExceptionHandler(InvalidPasswordException.class) @ResponseBody public ControllerAdviceExceptionMessage handleInvalidPasswordException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeInvalidPasswordException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
InvalidPasswordException
object
-
handleDescendantsArchivedException
@ResponseStatus(METHOD_NOT_ALLOWED) @ExceptionHandler(DescendantsArchivedException.class) @ResponseBody public ControllerAdviceExceptionMessage handleDescendantsArchivedException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeDescendantsArchivedException
when they occur from methods executed from the controller.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
DescendantsArchivedException
object
-
defaultErrorHandler
@ResponseStatus(INTERNAL_SERVER_ERROR) @ExceptionHandler(java.lang.Exception.class) @ResponseBody public ControllerAdviceExceptionMessage defaultErrorHandler(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Default exception handler. Will catch all bad requests, but will not provide further details of the error.- Parameters:
req
- servlet requeste
- general exception- Returns:
- a
ControllerAdviceExceptionMessage
object
-
-