Class HawaiiResponseEntityExceptionHandler

java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
org.hawaiiframework.web.exception.HawaiiResponseEntityExceptionHandler
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.MessageSourceAware

@Order @ControllerAdvice public class HawaiiResponseEntityExceptionHandler extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
This class creates proper HTTP response bodies for exceptions.
Since:
2.0.0
  • 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
    The constructor with a errorResponseEntityBuilder.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<Object>
    handleApiException(ApiException exception, org.springframework.web.context.request.WebRequest request)
    Handles ValidationException instances.
    org.springframework.http.ResponseEntity<Object>
    handleHttpException(HttpException exception, org.springframework.web.context.request.WebRequest request)
    Handles HttpException instances.
    protected org.springframework.http.ResponseEntity<Object>
    handleMethodArgumentNotValid(org.springframework.web.bind.MethodArgumentNotValidException exception, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request)
    Handles MethodArgumentNotValidException instances.
    org.springframework.http.ResponseEntity<Object>
    handleThrowable(Throwable throwable, org.springframework.web.context.request.WebRequest request)
    Handles Throwable instances.
    org.springframework.http.ResponseEntity<Object>
    handleValidationException(ValidationException exception, org.springframework.web.context.request.WebRequest request)
    Handles ValidationException instances.

    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, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource

    Methods inherited from class java.lang.Object

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

    • HawaiiResponseEntityExceptionHandler

      public HawaiiResponseEntityExceptionHandler(ErrorResponseEntityBuilder errorResponseEntityBuilder)
      The constructor with a errorResponseEntityBuilder.
  • Method Details

    • handleHttpException

      @ExceptionHandler(HttpException.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleHttpException(HttpException exception, org.springframework.web.context.request.WebRequest request)
      Handles HttpException instances.

      Each HttpException has an associated HttpStatus that is used as the response status.

      Parameters:
      exception - the exception
      request - the current request
      Returns:
      a response entity reflecting the current exception
    • handleMethodArgumentNotValid

      protected org.springframework.http.ResponseEntity<Object> handleMethodArgumentNotValid(@NonNull org.springframework.web.bind.MethodArgumentNotValidException exception, @NonNull org.springframework.http.HttpHeaders headers, @NonNull org.springframework.http.HttpStatusCode status, @NonNull org.springframework.web.context.request.WebRequest request)
      Handles MethodArgumentNotValidException instances.

      The response status is: 400 Bad Request.

      Overrides:
      handleMethodArgumentNotValid in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
      Parameters:
      exception - the exception
      request - the current request
      Returns:
      a response entity reflecting the current exception
    • handleValidationException

      @ExceptionHandler(ValidationException.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleValidationException(ValidationException exception, org.springframework.web.context.request.WebRequest request)
      Handles ValidationException instances.

      The response status is: 400 Bad Request.

      Parameters:
      exception - the exception
      request - the current request
      Returns:
      a response entity reflecting the current exception
    • handleApiException

      @ExceptionHandler(ApiException.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleApiException(ApiException exception, org.springframework.web.context.request.WebRequest request)
      Handles ValidationException instances.

      The response status is: 400 Bad Request.

      Parameters:
      exception - the exception
      request - the current request
      Returns:
      a response entity reflecting the current exception
    • handleThrowable

      @ExceptionHandler(java.lang.Throwable.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleThrowable(Throwable throwable, org.springframework.web.context.request.WebRequest request)
      Handles Throwable instances. This method acts as a fallback handler.
      Parameters:
      throwable - the exception
      request - the current request
      Returns:
      a response entity reflecting the current exception