APP崩溃:致命异常:io.reactivex.exceptions.CompositeException

Shw*_*han 0 android reactivex retrofit2

使用retrofitI调用API获取列表,但是当没有找到数据时,我正在调用onErrorGetOccasionmethod HttpException,为此,我按照代码中所示的方式进行处理。

现在我的问题有时onErrorGetOccasion是致命的

Exception: io.reactivex.exceptions.CompositeException this error and app crash.
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

//Get Occasion API
private void callGetOccasionAPI(String pageIndex, boolean isDialogShown) {

    if (NetworkUtils.isConnected()) {
        if (mPageCount == 1 && isDialogShown)
            showProgressDialog(mContext);
        RetrofitAdapter.createRetroServiceWithSessionToken(mContext)
                .getOccasion(pageIndex)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this::onSuccessGetOccasion, this::onErrorGetOccasion);
    } else {
        SnackBarUtils.defaultSnackBar(getString(R.string.error_no_internet), mRootView);
    }
}

private void onErrorGetOccasion(Throwable throwable) {
    hideProgressDialog();
    if (throwable instanceof HttpException) {
        ResponseBody body = ((HttpException) throwable).response().errorBody();
        Utils.setLog(body != null ? body.toString() : null);
        try {
            if (body != null) {
                if (body.string().contains(mContext.getString(R.string.msg_event_not_found))) {
                    if (mPageCount == 1) {
                        mTxtRecordNotFound.setVisibility(View.VISIBLE);
                        mRecyclerView.setVisibility(View.INVISIBLE);
                    }
                } else {
                    SnackBarUtils.errorSnackBar(getString(R.string.error_api), mRootView, null);
                }
            }

        } catch (IOException e) {
            e.printStackTrace();
            Crashlytics.log(e.getMessage());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

elm*_*bea 5

CompositeException 通常在您的错误处理程序处理流中抛出的错误时自身抛出异常时引发。

确保您的错误处理代码没有引发任何异常。

通常,堆栈跟踪的根本原因在下方CompositeException,并带有Caused by

  • 如何处理? (2认同)