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.ObjectController-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 ControllerAdviceExceptionMessagedefaultErrorHandler(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Default exception handler.ControllerAdviceExceptionMessagehandleAccessDeniedException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeAccessDeniedExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleConcurencyCheckedFailed(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeOptimisticLockingFailureExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleDeniedAuthorization(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeUserDeniedAuthorizationExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleDescendantsArchivedException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeDescendantsArchivedExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleInvalidPasswordException(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeInvalidPasswordExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleRefInUseFailure(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeOptimisticLockingFailureExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleResourceNotFound(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeResourceNotFoundExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleRetrievalFailure(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeOptimisticLockingFailureExceptionwhen they occur from methods executed from the controller.ControllerAdviceExceptionMessagehandleUserByEmailNotFound(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)Handle all exceptions of typeUserNotFoundExceptionwhen 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 typeResourceNotFoundExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
ControllerAdviceExceptionMessageobject
-
handleUserByEmailNotFound
@ResponseStatus(NOT_FOUND) @ExceptionHandler(UserNotFoundException.class) @ResponseBody public ControllerAdviceExceptionMessage handleUserByEmailNotFound(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeUserNotFoundExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
ControllerAdviceExceptionMessageobject
-
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 typeUserDeniedAuthorizationExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
ControllerAdviceExceptionMessageobject
-
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 typeOptimisticLockingFailureExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
ControllerAdviceExceptionMessageobject
-
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 typeOptimisticLockingFailureExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
ControllerAdviceExceptionMessageobject
-
handleRefInUseFailure
@ResponseStatus(CONFLICT) @ExceptionHandler(ReferenceInUseException.class) @ResponseBody public ControllerAdviceExceptionMessage handleRefInUseFailure(javax.servlet.http.HttpServletRequest req, java.lang.Exception e)
Handle all exceptions of typeOptimisticLockingFailureExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
ControllerAdviceExceptionMessageobject
-
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 typeAccessDeniedExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
AccessDeniedExceptionobject
-
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 typeInvalidPasswordExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
InvalidPasswordExceptionobject
-
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 typeDescendantsArchivedExceptionwhen they occur from methods executed from the controller.- Parameters:
req- servlet requeste- general exception- Returns:
- a
DescendantsArchivedExceptionobject
-
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
ControllerAdviceExceptionMessageobject
-
-