Class ExceptionControllerAdvice


  • @ControllerAdvice
    public class ExceptionControllerAdvice
    extends java.lang.Object
    Handles exceptions thrown by all of the controllers
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String notAjaxRequest​(NotAjaxRequest e)
      Handles requests which are only allowed to be ajax requests.
      java.lang.String notAuthorisedError​(org.springframework.ui.Model model, org.springframework.security.core.Authentication authentication, java.lang.Exception e)
      Handles all requests which are not authorised
      java.lang.String notFoundError​(org.springframework.ui.Model model, org.springframework.security.core.Authentication authentication, java.lang.Exception e)
      Handles all "not found" errors
      java.lang.String notInitialised​(org.springframework.ui.Model model, java.lang.Exception e)
      Handles requests which occur before Spring has finished starting up
      java.lang.String runtimeError​(org.springframework.ui.Model model, java.lang.Exception e)
      Handles all generic/unknown errors
      java.lang.String uploadSizeExceededError​(org.springframework.ui.Model model, org.springframework.security.core.Authentication authentication, java.lang.Exception e)
      Handles all requests where the user tried to upload files that are larger than allowed
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExceptionControllerAdvice

        public ExceptionControllerAdvice()
    • Method Detail

      • notInitialised

        @ExceptionHandler(SpringNotInitialised.class)
        @ResponseStatus(SERVICE_UNAVAILABLE)
        public java.lang.String notInitialised​(org.springframework.ui.Model model,
                                               java.lang.Exception e)
        Handles requests which occur before Spring has finished starting up
        Parameters:
        model - holder for model attributes
        e - the exception object
        Returns:
        the path to the error page
      • notAjaxRequest

        @ExceptionHandler(NotAjaxRequest.class)
        public java.lang.String notAjaxRequest​(NotAjaxRequest e)
        Handles requests which are only allowed to be ajax requests. Redirects the user to the url supplied in the error message, typically this is the page that contained the form/page element
        Parameters:
        e - the exception object
        Returns:
        the page to redirect to
      • runtimeError

        @ExceptionHandler({java.lang.Throwable.class,LoadingHelpFailed.class})
        @ResponseStatus(INTERNAL_SERVER_ERROR)
        public java.lang.String runtimeError​(org.springframework.ui.Model model,
                                             java.lang.Exception e)
        Handles all generic/unknown errors
        Parameters:
        model - holder for model attributes
        e - the exception object
        Returns:
        the path to the error page
      • notAuthorisedError

        @ExceptionHandler({NotTemplateOwner.class,AccountOwner.class})
        @ResponseStatus(FORBIDDEN)
        public java.lang.String notAuthorisedError​(org.springframework.ui.Model model,
                                                   org.springframework.security.core.Authentication authentication,
                                                   java.lang.Exception e)
        Handles all requests which are not authorised
        Parameters:
        model - holder for model attributes
        authentication - the authentication class
        e - the exception object
        Returns:
        the path to the error page
      • uploadSizeExceededError

        @ExceptionHandler(org.springframework.web.multipart.MaxUploadSizeExceededException.class)
        @ResponseStatus(PAYLOAD_TOO_LARGE)
        public java.lang.String uploadSizeExceededError​(org.springframework.ui.Model model,
                                                        org.springframework.security.core.Authentication authentication,
                                                        java.lang.Exception e)
        Handles all requests where the user tried to upload files that are larger than allowed
        Parameters:
        model - holder for model attributes
        authentication - the authentication class
        e - the exception object
        Returns:
        the path to the error page