user3186731 user3186731 - 1 month ago 15
Android Question

The Best Way to Debug Retrofit Error Messages

I'm new to Retrofit. I have used Volley, and I kind of like Retrofit. I was just about to select Retrofit when I ran into this very non-descriptive error message when trying to do a POST.

Exception in thread "main" retrofit.RetrofitError
at retrofit.RetrofitError.httpError(RetrofitError.java:37)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:413)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:282)
at myapi.api.$Proxy7.logon(Unknown Source)
at myapi.api.TestDriver.main(TestDriver.java:94)


Well, I must say that this type of error message is about as useful as a warm jacket in the Sahara.

Does anyone even know where to begin with debugging this type of message? I really am not about to delegate to a REST api that does not provide useful error messages.

Answer

You probably want to add a catch clause to TestDriver.main:

try {
  service.logon();
} catch (RetrofitError e) {
  System.out.println(e.getResponse().getStatus());
}