Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to RxJavaErrorHandler #4566

Closed
bobvanderlinden opened this issue Sep 19, 2016 · 5 comments
Closed

Alternative to RxJavaErrorHandler #4566

bobvanderlinden opened this issue Sep 19, 2016 · 5 comments

Comments

@bobvanderlinden
Copy link
Contributor

I'd like to catch unhandled errors that arise from Observables globally.

The documentation here suggests to use RxJavaPlugins.getInstance().registerErrorHandler, but both getInstance and RxJavaErrorHandler are deprecated with no hints as what to use instead.

The documentation on error handling in RxJava here also has no mention of globally handling errors.

I did find RxJavaHooks.setOnError, but I have not found any documentation on this, so I was unsure whether it should be used.

Is this still on-going work or can anyone suggest what to use as an alternative to registerErrorHandler?

@aaronweihe
Copy link
Contributor

The documentation on the Wiki is probably outdated. If you look at the java doc of RxJavaPlugins#getInstance(), it says

Deprecated. use the static methods of RxJavaHooks.

😄

@akarnokd
Copy link
Member

Hi and thanks for the feedback. Those articles are a bit outdated and will be updated in a few days to better reflect the current status with 1.2.

I did find RxJavaHooks.setOnError, but I have not found any documentation on this, so I was unsure whether it should be used.

There is not much to that method. By default, undeliverable exceptions are routed to RxJavaHooks.onError which then calls an Action1<Throwable> you can change via RxJavaHooks.setOnError.

Here is the release info and the PR

@bobvanderlinden
Copy link
Contributor Author

Thank you both for the feedback. RxJavaHooks.setOnError it is! I've made a PR that documents the new alternative (#4569).

@akarnokd
Copy link
Member

Updated the Plugins wiki page. Let me know if it's adequate for you.

@bobvanderlinden
Copy link
Contributor Author

@akarnokd Yes, that makes things a lot more clear. Thank you!

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

No branches or pull requests

3 participants