title: How to get the HTTP error code from a failed request in Retrofit 2.0.0?
body: <p>I am making call using the following callback method:</p>
  
  <pre><code>Callback&lt;PeopleList&gt; callback = new Callback&lt;PeopleList&gt;() {
      @Override
      public void onResponse(Response&lt;PeopleList&gt; response) {
          Toast.makeText(LoginActivity.this,getString(R.string.login_failed), Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onFailure(Throwable t) {
          Toast.makeText(LoginActivity.this,getString(R.string.login_failed), Toast.LENGTH_SHORT).show();
      }
  };
  
  Retrofit retrofit = new Retrofit.Builder()
              .baseUrl("https://example.com/")
              .addConverterFactory(GsonConverterFactory.create())
              .build();
  retrofit.create(MyService.class).getPeopleData().enqueue(callback);
  </code></pre>
  
  <p>To the following interface:</p>
  
  <pre><code>public interface MyService {
  
      @Headers("Accept: application/json")
      @GET("/data/people/")
      Call&lt;PeopleList&gt; getPeopleData();
  }
  </code></pre>
  
  <p>This callback works just fine on successful requests. On unsuccessful ones however it does not give me the opportunity to investigate further as the onFailure method does not allow me to retrieve the http error code that came with the response. </p>
  
  <p>On investigating further I found that according to several stackoverflow threads, the onResponse method should be called even on unsuccessful requests. This however seems to be at odds not only with my personal experience but also with the documentation of the Callback interface, which states that: </p>
  
  <blockquote>
    <p>Communicates responses from a server or offline requests. One and only one method will be
     invoked in response to a given request.</p>
  </blockquote>
  
  <p>So the question is, how do I get the HTTP error code from a failed response if the onResponse method isn't called?</p>