Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Error Handling #19

Open
agraebe opened this issue Jun 26, 2016 · 0 comments
Open

Improved Error Handling #19

agraebe opened this issue Jun 26, 2016 · 0 comments

Comments

@agraebe
Copy link

agraebe commented Jun 26, 2016

Right now, the retrofit2 lib returns a response that could have failed, for instance by mixing up server_token and OAuth authentication methods. Getting an understandable error is not as easy as it could be:

Response<UserProfile> response = service.getUserProfile().execute();
        if (response.isSuccessful()) {
            // Success
            UserProfile profile = response.body();
            System.out.println(profile.toString());
        } else {
            // Failure
            ApiError error = ErrorParser.parseError(response);
            List<ClientError> errors = error.getClientErrors();
            // show error code and message
            for (int i = 0; i < errors.size(); i++) {
                System.out.println(error.getClientErrors().get(i).getStatus() + " "
                        + error.getClientErrors().get(i).getCode() + ": " + error.getClientErrors().get(i).getTitle());
            }
        }

Every user would need to loop through the whole error list. A simple method would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant