Class DefaultExceptionResponseFactory
java.lang.Object
org.hawaiiframework.web.exception.DefaultExceptionResponseFactory
- All Implemented Interfaces:
ExceptionResponseFactory
@Component
public class DefaultExceptionResponseFactory
extends Object
implements ExceptionResponseFactory
Default implementation of
ExceptionResponseFactory
.
The default implementation creates an ApiErrorResponseResource
if the exception is an ApiException
and a ErrorResponseResource
in all other cases.- Since:
- 2.0.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate the response resource.
-
Constructor Details
-
DefaultExceptionResponseFactory
public DefaultExceptionResponseFactory()
-
-
Method Details
-
create
Create the response resource.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 aHawaiiException
, the throwable itself is used.As an example, assume throwable is some type of
HttpException
, caused by anApiException
. In such a case, we want the error information to be derived from theApiException
.- Specified by:
create
in interfaceExceptionResponseFactory
- Parameters:
throwable
- the throwable- Returns:
- the error resource
-