Skip to content

Improved Error Handling #19

@agraebe

Description

@agraebe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions