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.
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:
Every user would need to loop through the whole error list. A simple method would be helpful.