문제

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.

도움이 되었습니까?

해결책

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'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top