Class DefaultExceptionResponseFactory
- java.lang.Object
-
- org.hawaiiframework.web.exception.DefaultExceptionResponseFactory
-
- All Implemented Interfaces:
ExceptionResponseFactory
@Component public class DefaultExceptionResponseFactory extends Object implements ExceptionResponseFactory
Default implementation ofExceptionResponseFactory
. The default implementation creates anApiErrorResponseResource
if the exception is anApiException
and aErrorResponseResource
in all other cases.- Since:
- 2.0.0
- Author:
- Paul Klos
-
-
Constructor Summary
Constructors Constructor Description DefaultExceptionResponseFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ErrorResponseResource
create(Throwable throwable)
Create the response resource.
-
-
-
Method Detail
-
create
public ErrorResponseResource create(Throwable throwable)
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
-
-