@Component public class DefaultExceptionResponseFactory extends Object implements ExceptionResponseFactory
ExceptionResponseFactory
.
The default implementation creates an ApiErrorResponseResource
if the exception is an ApiException
and a ErrorResponseResource
in all other cases.Constructor and Description |
---|
DefaultExceptionResponseFactory() |
Modifier and Type | Method and Description |
---|---|
ErrorResponseResource |
create(Throwable throwable)
Create the response resource.
|
public ErrorResponseResource create(Throwable throwable)
If present, the first HawaiiException
found in the cause chain of the throwable is used
to determine the response type. If there is no cause, or if it doesn't contain a HawaiiException
,
the throwable itself is used.
As an example, assume throwable is some type of HttpException
, caused by an ApiException
. In such a case,
we want the error information to be derived from the ApiException
.
create
in interface ExceptionResponseFactory
throwable
- the throwable