我有以下代码用于错误处理。我的问题是,当服务器发送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 -> {
}
);}