ResponseHandler<RedditRequestResponse> rh = new ResponseHandler<RedditRequestResponse>() {
@Override
public RedditRequestResponse handleResponse(
final HttpResponse response) throws IOException, RedditException {
int statusCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
if (entity == null) {
throw new ClientProtocolException("Response contains no content");
}
String responseBody = EntityUtils.toString(entity);
if (statusCode != HttpStatus.SC_OK) {
throw new RedditException(generateErrorString(statusCode, input, responseBody));
}
return new RedditRequestResponse(statusCode, responseBody);
}
};
I'd like to throw my own RedditException from handleResponse() that includes the response body. However, when I try that (like in the above code) I get a RedditException not compatible with throws clause error. I suspect this has something to do with the @Override. What exactly is being overridden? The class that contains this method does not inherit from any other class and does not implement any interfaces that I can tell.