use of org.folio.inventory.exceptions.NotFoundException in project mod-inventory by folio-org.
the class EndpointFailureHandler method handleFailure.
public static void handleFailure(Throwable failure, RoutingContext context) {
final Throwable failureToHandle = getKnownException(failure);
if (failureToHandle instanceof UnprocessableEntityException) {
UnprocessableEntityException validationFailure = (UnprocessableEntityException) failureToHandle;
unprocessableEntity(context.response(), validationFailure.getMessage(), validationFailure.getPropertyName(), validationFailure.getPropertyValue());
} else if (failureToHandle instanceof NotFoundException) {
ClientErrorResponse.notFound(context.response(), failureToHandle.getMessage());
} else if (failureToHandle instanceof ExternalResourceFetchException) {
final ExternalResourceFetchException externalException = (ExternalResourceFetchException) failureToHandle;
forward(context.response(), externalException.getBody(), externalException.getStatusCode(), externalException.getContentType());
} else {
ServerErrorResponse.internalError(context.response(), failureToHandle);
}
}
Aggregations