2
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.

1 Answer 1

3

If you make your RedditException extend an IOException then you will be able to get around it by keeping the same method signature

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.