-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Proposal: Move the checks for missing onError() higher on the chain #4022
Comments
The (poorly named) rxlint library adds a lint check for missing
These types of things are true of every platform and every library though. How many developers have empty |
Hello @JakeWharton, i fixed the title. My point is that there should be something that would throw an Exception at compile time. It is not a 100% possibility that you would catch an Exception on your Observable's flow, in order to know about the missing onError() method. Why not fail-early, instead of having to add another plugin/linter/dependency on your dev stack, such as rxlint that you mentioned? |
Because it's perfectly reasonable to omit error handling in streams for which it is not required or in which things like the |
Agree on that. So what you are saying is that there is no reason to fail-early in such case and just leave it as is? Couldn't this be balanced in some way? Provide at least some NonNull annotation or something so it could be at least reported to the developer and he/she will choose or not to Disable the Inspection? |
I'm not saying there's no reason to fail early. RxLint seems like a way to accomplish what you want, in that it will fail your build if you use one of the |
Great! Thank you for your insight on this :) Have a nice day! |
Hello to everyone.
I would like to propose a change on the RxJava API, in order to avoid crashes of application's that have not properly implemented onError in the defined Subscribers.
Actually a real case scenario, happened the other day at Droidcon Berlin's 2016 App. The onError method was not implemented and on the case that anyone opened the application while being offline, the application itself would crash just because it produced an error that was not able to be propagated anywhere because there was not any onError method available.
This granted and knowing that this is a mistake that most if not all engineers would stumble upon at least once when they start with RxJava, I think that there should be a pattern of fail-very-early for this case.
It is completely understandable, that this is a Developer's/Engineer's mistake and wrong implementation, but it does not clearly set a restriction or does not force at all, anyone who uses a .subscribe() on an Observable, to implement the .onError() method.
So if you do not happen to write tests, which is not the common case scenario, and you also do not happen to stumble upon an Error that throws an Exception, you might possibly if not 100% ship an application that would crash in the future just because your subscription is missing the .onError() method.
I will be very glad to discuss it and read the different opinions on this issue :)
The text was updated successfully, but these errors were encountered: