use of uk.gov.gchq.gaffer.core.exception.GafferWrappedErrorRuntimeException in project Gaffer by gchq.
the class ProxyStore method handleResponse.
protected <O> O handleResponse(final Response response, final ResponseDeserialiser<O> responseDeserialiser) throws StoreException {
final String outputJson = response.hasEntity() ? response.readEntity(String.class) : null;
if (Family.SUCCESSFUL != response.getStatusInfo().getFamily()) {
final Error error;
try {
error = JSONSerialiser.deserialise(StringUtil.toBytes(outputJson), Error.class);
} catch (final Exception e) {
LOGGER.warn("Gaffer bad status {}. Detail: {}", response.getStatus(), outputJson);
throw new StoreException("Delegate Gaffer store returned status: " + response.getStatus() + ". Response content was: " + outputJson);
}
throw new GafferWrappedErrorRuntimeException(error);
}
O output = null;
if (null != outputJson) {
try {
output = responseDeserialiser.deserialise(outputJson);
} catch (final SerialisationException e) {
throw new StoreException(e.getMessage(), e);
}
}
return output;
}
use of uk.gov.gchq.gaffer.core.exception.GafferWrappedErrorRuntimeException in project Gaffer by gchq.
the class ProxyStoreBasicIT method shouldCatchAndThrowUsefulErrorMessages.
@Test
public void shouldCatchAndThrowUsefulErrorMessages() throws Exception {
// Given
addDefaultElements();
// When / Then
try {
graph.execute(new OperationChain.Builder().first(new GetAllElements()).then(new Limit<>(1, false)).then(new ToList<>()).build(), USER);
fail("Exception expected");
} catch (final GafferWrappedErrorRuntimeException e) {
assertThat(e.getError()).isEqualTo(new Error.ErrorBuilder().simpleMessage("Limit of 1 exceeded.").status(Status.INTERNAL_SERVER_ERROR).build());
}
}
Aggregations