Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

UndeliverableException unhandled #213

Open
jurepetrovic opened this issue Aug 1, 2018 · 2 comments
Open

UndeliverableException unhandled #213

jurepetrovic opened this issue Aug 1, 2018 · 2 comments

Comments

@jurepetrovic
Copy link

Hello Gentlemen,

I'm getting

Stack Trace: io.reactivex.exceptions.UndeliverableException: java.net.UnknownHostException: ws.pusherapp.com

due to connection problems.
Where could I override onError() to catch this?
And where does it get thrown?
I can catch it only grom uncaught Exception handler in main class...

@jurepetrovic
Copy link
Author

Is there any option I could use RxJavaPlugin.setErrorHandler() ?
This way I could set my own handler for this kind of errors..?

@jurepetrovic
Copy link
Author

I'm looking a this page:

https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling

It seems that unpredictable network errors (like sudden connection loss) need to be handled in exta global handler, that is part of RxJava package. Has anyone worked on that?

RxJavaPlugins.setErrorHandler(e -> {
    if (e instanceof UndeliverableException) {
        e = e.getCause();
    }
    if ((e instanceof IOException) || (e instanceof SocketException)) {
        // fine, irrelevant network problem or API that throws on cancellation
        return;
    }
    if (e instanceof InterruptedException) {
        // fine, some blocking code was interrupted by a dispose call
        return;
    }
    if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) {
        // that's likely a bug in the application
        Thread.currentThread().getUncaughtExceptionHandler()
            .handleException(Thread.currentThread(), e);
        return;
    }
    if (e instanceof IllegalStateException) {
        // that's a bug in RxJava or in a custom operator
        Thread.currentThread().getUncaughtExceptionHandler()
            .handleException(Thread.currentThread(), e);
        return;
    }
    Log.warning("Undeliverable exception received, not sure what to do", e);
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants