Class ErrorResponseEntityBuilder
java.lang.Object
org.hawaiiframework.web.exception.ErrorResponseEntityBuilder
This class creates proper HTTP response bodies for exceptions.
- Since:
- 6.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionErrorResponseEntityBuilder
(ExceptionResponseFactory exceptionResponseFactory, List<ErrorResponseEnricher> errorResponseEnrichers) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResponseEnricher
(ErrorResponseEnricher errorResponseEnricher) Registers aErrorResponseEnricher
.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.Returns a collection of registered response enrichers.void
removeResponseEnricher
(ErrorResponseEnricher errorResponseEnricher) De-registers aErrorResponseEnricher
.
-
Constructor Details
-
ErrorResponseEntityBuilder
public ErrorResponseEntityBuilder(ExceptionResponseFactory exceptionResponseFactory, List<ErrorResponseEnricher> errorResponseEnrichers)
-
-
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
usingexceptionResponseFactory
and then applies the error response enrichers returned fromgetResponseEnrichers()
to complete the response.- Parameters:
throwable
- the exceptionstatus
- the HTTP statusrequest
- the current request- Returns:
- an error response
-
addResponseEnricher
Registers aErrorResponseEnricher
.- Parameters:
errorResponseEnricher
- the error response enricher
-
removeResponseEnricher
De-registers aErrorResponseEnricher
.- Parameters:
errorResponseEnricher
- the error response enricher
-
getResponseEnrichers
Returns a collection of registered response enrichers.- Returns:
- the response enrichers
-