Class ErrorResponseEntityBuilder

java.lang.Object
org.hawaiiframework.web.exception.ErrorResponseEntityBuilder

public class ErrorResponseEntityBuilder extends Object
This class creates proper HTTP response bodies for exceptions.
Since:
6.0.0
  • Constructor Details

  • Method Details

    • buildErrorResponseBody

      public ErrorResponseResource buildErrorResponseBody(Throwable throwable, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)
      Builds a meaningful response body for the given throwable, HTTP status and request.

      This method constructs an ErrorResponseResource using exceptionResponseFactory and then applies the error response enrichers returned from getResponseEnrichers() to complete the response.

      Parameters:
      throwable - the exception
      status - the HTTP status
      request - the current request
      Returns:
      an error response
    • addResponseEnricher

      public void addResponseEnricher(ErrorResponseEnricher errorResponseEnricher)
      Parameters:
      errorResponseEnricher - the error response enricher
    • removeResponseEnricher

      public void removeResponseEnricher(ErrorResponseEnricher errorResponseEnricher)
      De-registers a ErrorResponseEnricher.
      Parameters:
      errorResponseEnricher - the error response enricher
    • getResponseEnrichers

      public Collection<ErrorResponseEnricher> getResponseEnrichers()
      Returns a collection of registered response enrichers.
      Returns:
      the response enrichers