3

I am using Retrofit for my backend communication: If the status code is not 200 then the callback call failure method. But I want to get the status code inside the failure method for further code conditioning

        @Override
        public void failure(RetrofitError retrofitError) {

                Logger.e("ERROR Status:", retrofitError.getResponse().getStatus() + "");

            }
        }

But the above code always give a null pointer exception. How do i get the status code of my header on failure.

Please help.

Thanks in advance.

AabidMulani
  • 2,325
  • 1
  • 28
  • 47

1 Answers1

5

This is a bug. Add OkHttp's latest version to your dependencies.

compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
sjagr
  • 15,983
  • 5
  • 40
  • 67
interlude
  • 843
  • 8
  • 29