RxJava2:onErrorResumeNext不拦截400响应代码

时间:2018-10-28 19:44:19

标签: java android retrofit2 rx-java2

我有以下代码用于错误处理。我的问题是,当服务器发送400错误代码时,不会调用onErrorResumeNext。这是预期的吗?我以为服务器发送非200码(200-300)时会调用onErrorResumeNext。

public Single adapt(Call c) {
 return ((Single) adapt(c)
         .onErrorResumeNext(new Function() {
         //BELOW NOT BEING EXECUTED ON 400 error from server.
         @Override
         public Object apply(Object throwable) throws Exception {

                 return Single.error(DoSomethingWithException((Throwable) throwable));
                 }
         }).subscribeOn(Schedulers.newThread())
           .observerOn(AndroidSchedulers.mainThread())
           .flatMap( response -> {

          }
          );}

0 个答案:

没有答案