Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 即使已在onError中处理,仍引发了Reform2.HttpException_Java_Rx Java_Retrofit2 - Fatal编程技术网

Java 即使已在onError中处理,仍引发了Reform2.HttpException

Java 即使已在onError中处理,仍引发了Reform2.HttpException,java,rx-java,retrofit2,Java,Rx Java,Retrofit2,当google+响应错误json时,我总是收到一个未处理的异常 retrofit2.HttpException: HTTP 404 at retrofit2.RxJavaCallAdapterFactory$SimpleCallAdapter$1.call(RxJavaCallAdapterFactory.java:159) at retrofit2.RxJavaCallAdapterFacto

当google+响应错误json时,我总是收到一个未处理的异常

retrofit2.HttpException: HTTP 404 
                         at retrofit2.RxJavaCallAdapterFactory$SimpleCallAdapter$1.call(RxJavaCallAdapterFactory.java:159)
                         at retrofit2.RxJavaCallAdapterFactory$SimpleCallAdapter$1.call(RxJavaCallAdapterFactory.java:154)
                         at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
                         at retrofit2.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:109)
                         at retrofit2.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:88)
                         at rx.Observable$2.call(Observable.java:162)
                         at rx.Observable$2.call(Observable.java:154)
                         at rx.Observable$2.call(Observable.java:162)
                         at rx.Observable$2.call(Observable.java:154)
                         ....
在该法典中:

Observable.create(new Observable.OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> strSub) {
            // Getting ID
            strSub.onNext(AccountUtils.getAccountId(appContext));
            strSub.onCompleted();})

          .subscribeOn(Schedulers.io())
          // Get Google+ Image through Retrofit2
          .flatMap(str -> createGPlusUserObservable(str, AccountUtils.ANDROID_API_KEY))
          .map(this::setprofileImage)    // I don't see Timber.d message inside that method!
          .compose(binder)
          .observeOn(AndroidSchedulers.mainThread())
          .subscribe(subscriber);
所以问题是-如果我在订户的onError(Throwable e)中处理它,为什么会得到未处理的异常


谢谢

我认为这是因为在将纯html字符串转换为我的GPlusUser类时,改装工厂逻辑时发生了错误


我通过
可观察的响应
响应来处理纯html,从而消除了控制台日志中令人讨厌的异常。isSuccess()

您可以发布“setprofileImage”的代码吗?请参阅更新。谢谢
private Observable<GPlusUser> createGPlusUserObservable(String userId, String apiKey) {
    //try {
    GoogleApiService service = ServiceFactory.getInstance().createJsonRetrofitService(
            GoogleApiService.class,
            GoogleApiService.SERVICE_ENDPOINT
    );

    Observable<GPlusUser> result = service.getGPlusUserInfo(userId, apiKey);
    Timber.d("Here1!"); // I see that in console!
    return result;  // It always returns result!
    /*} catch (Throwable e) { - it doesn't catch anything!
        Timber.d("Here!");
    }*/
}
new Subscriber<GPlusUser>() {
        @Override
        public void onCompleted() {
            Timber.d("GPlusUserSubscriber ON COMPLETED");
        }

        @Override
        public void onError(Throwable e) {
            if (e instanceof HttpException) {
                Timber.d("RETROFIT!"); // I see that in console!
            }
        }

        @Override
        public void onNext(GPlusUser gPlusUser) {
            setupAccountBox();
        }
    };
private GPlusUser setprofileImage(GPlusUser gPlusUser) {
    Timber.d("FOUR"); // As I've said, it doesn't appear in console
    AccountUtils.setProfileImage(appContext, gPlusUser.image.url);
    Timber.d("Setting profile image: %s", gPlusUser.image.url);
    return gPlusUser;
}