// since there shouldn't be any content as the status implies
result.successful();
} else if (response.hasFailed()) {
result.failed(response.failureCause());
if (config.isAllowedToRaiseExceptions()) {
throw new DataSiftException("API request failed", response.failureCause(), response);
}
} else {
try {
result = (T) DataSiftClient.MAPPER.readValue(s, instance.getClass());
} catch (IOException e) {
result.failed(e);
if (config.isAllowedToRaiseExceptions()) {
throw new JsonParsingException("Unable to decode JSON from DataSift response", e, response);
}
}
}
result.setResponse(new com.datasift.client.Response(s, response));
if (config.isAllowedToRaiseExceptions() && response.getStatus().code() == 401) {
throw new AuthException("Please provide a valid username and API key", response);
}
if (config.isAllowedToRaiseExceptions() && !result.isSuccessful()) {
throw new DataSiftException(result.getError(), result.failureCause());
}
future.received(result);
}
};
}