Class LocalifyExceptionHandler

java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
org.localify.common.LocalifyExceptionHandler
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.MessageSourceAware

@ControllerAdvice @Order(-2147483648) @ConditionalOnWebApplication public class LocalifyExceptionHandler extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
Our main exception handler for the entire application. As we don't use nor care about MVC pages with accept negotiation yada yada yada, everything is handled here
  • Field Summary

    Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

    logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected @NotNull org.springframework.http.ResponseEntity<Object>
    createResponseEntity(Object passedBody, @NotNull org.springframework.http.HttpHeaders headers, @NotNull org.springframework.http.HttpStatusCode statusCode, org.springframework.web.context.request.WebRequest request)
     
    handleAccessDenied(org.springframework.security.access.AccessDeniedException ex)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleAuthenticationCredentialsNotFound(org.springframework.security.core.AuthenticationException ex, org.springframework.web.context.request.WebRequest request)
    Called when spring requires authentication, but nothing was in the security context.
    protected org.springframework.http.ResponseEntity<Object>
    handleAuthenticationException(org.springframework.security.core.AuthenticationException ex, org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleBaseExceptionFallback(Exception ex, org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleConcurrentCompletionException(CompletionException ex, org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleErrorResponseException(@NotNull org.springframework.web.ErrorResponseException ex, @NotNull org.springframework.http.HttpHeaders headers, @NotNull org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleExceptionInternal(@NotNull Exception ex, Object body, @NotNull org.springframework.http.HttpHeaders headers, @NotNull org.springframework.http.HttpStatusCode statusCode, @NotNull org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleExceptionWithMessage(org.springframework.http.HttpStatusCode code, Exception ex, org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleMethodArgumentNotValid(@NotNull org.springframework.web.bind.MethodArgumentNotValidException ex, @NotNull org.springframework.http.HttpHeaders headers, @NotNull org.springframework.http.HttpStatusCode status, @NotNull org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleNoHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request)
     
    protected org.springframework.http.ResponseEntity<Object>
    handleResponseStatusException(org.springframework.web.server.ResponseStatusException ex, org.springframework.web.context.request.WebRequest request)
     

    Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

    createProblemDetail, getMessageSource, handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMissingPathVariable, handleMissingServletRequestPart, handleServletRequestBindingException, handleTypeMismatch, setMessageSource

    Methods inherited from class java.lang.Object

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

    • LocalifyExceptionHandler

      public LocalifyExceptionHandler()
  • Method Details

    • handleMissingServletRequestParameter

      @Nullable protected org.springframework.http.ResponseEntity<Object> handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request)
      Overrides:
      handleMissingServletRequestParameter in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    • handleMethodArgumentNotValid

      protected org.springframework.http.ResponseEntity<Object> handleMethodArgumentNotValid(@NotNull @NotNull org.springframework.web.bind.MethodArgumentNotValidException ex, @NotNull @NotNull org.springframework.http.HttpHeaders headers, @NotNull @NotNull org.springframework.http.HttpStatusCode status, @NotNull @NotNull org.springframework.web.context.request.WebRequest request)
      Overrides:
      handleMethodArgumentNotValid in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    • handleErrorResponseException

      protected org.springframework.http.ResponseEntity<Object> handleErrorResponseException(@NotNull @NotNull org.springframework.web.ErrorResponseException ex, @NotNull @NotNull org.springframework.http.HttpHeaders headers, @NotNull @NotNull org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request)
      Overrides:
      handleErrorResponseException in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    • handleNoHandlerFoundException

      @Nullable protected org.springframework.http.ResponseEntity<Object> handleNoHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request)
      Overrides:
      handleNoHandlerFoundException in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    • handleAuthenticationCredentialsNotFound

      @ExceptionHandler(org.springframework.security.authentication.AuthenticationCredentialsNotFoundException.class) protected org.springframework.http.ResponseEntity<Object> handleAuthenticationCredentialsNotFound(@NonNull org.springframework.security.core.AuthenticationException ex, @NonNull org.springframework.web.context.request.WebRequest request)
      Called when spring requires authentication, but nothing was in the security context.

      The cause (potential) of us ending up here can be found in the servlet attribute ServletAttributes.AUTH_EXCEPTION.

    • handleConcurrentCompletionException

      @ExceptionHandler(java.util.concurrent.CompletionException.class) protected org.springframework.http.ResponseEntity<Object> handleConcurrentCompletionException(@NonNull CompletionException ex, @NonNull org.springframework.web.context.request.WebRequest request)
    • handleAuthenticationException

      @ExceptionHandler(org.springframework.security.core.AuthenticationException.class) protected org.springframework.http.ResponseEntity<Object> handleAuthenticationException(@NonNull org.springframework.security.core.AuthenticationException ex, @NonNull org.springframework.web.context.request.WebRequest request)
    • handleBaseExceptionFallback

      @ExceptionHandler(java.lang.Exception.class) protected org.springframework.http.ResponseEntity<Object> handleBaseExceptionFallback(@NonNull Exception ex, @NonNull org.springframework.web.context.request.WebRequest request)
    • handleExceptionWithMessage

      protected org.springframework.http.ResponseEntity<Object> handleExceptionWithMessage(org.springframework.http.HttpStatusCode code, Exception ex, org.springframework.web.context.request.WebRequest request)
    • handleResponseStatusException

      @ExceptionHandler(org.springframework.web.server.ResponseStatusException.class) protected org.springframework.http.ResponseEntity<Object> handleResponseStatusException(org.springframework.web.server.ResponseStatusException ex, org.springframework.web.context.request.WebRequest request)
    • handleExceptionInternal

      @Nullable protected org.springframework.http.ResponseEntity<Object> handleExceptionInternal(@NotNull @NotNull Exception ex, @Nullable Object body, @NotNull @NotNull org.springframework.http.HttpHeaders headers, @NotNull @NotNull org.springframework.http.HttpStatusCode statusCode, @NotNull @NotNull org.springframework.web.context.request.WebRequest request)
      Overrides:
      handleExceptionInternal in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    • createResponseEntity

      @NotNull protected @NotNull org.springframework.http.ResponseEntity<Object> createResponseEntity(@Nullable Object passedBody, @NotNull @NotNull org.springframework.http.HttpHeaders headers, @NotNull @NotNull org.springframework.http.HttpStatusCode statusCode, org.springframework.web.context.request.WebRequest request)
      Overrides:
      createResponseEntity in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    • handleAccessDenied

      @ExceptionHandler(org.springframework.security.access.AccessDeniedException.class) @ResponseStatus(FORBIDDEN) public ErrorBody handleAccessDenied(org.springframework.security.access.AccessDeniedException ex)