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

2.x: Add explanation text to Undeliverable & OnErrorNotImplemented exs #6171

Merged
merged 3 commits into from
Aug 25, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Aug 24, 2018

This PR adds detailed error message to the UndeliverableException and OnErrorNotImplementedException as they are the most common exception-related questions around.

UndeliverableException

The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | <original exception message>

OnErrorNotImplementedException

The onError handler in the subscribe() method is not provided. Please specify it to avoid this type of exception. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | <original exception message>

@akarnokd
Copy link
Member Author

/cc @artem-zinnatullin @davidmoten

@codecov
Copy link

codecov bot commented Aug 24, 2018

Codecov Report

Merging #6171 into 2.x will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6171      +/-   ##
============================================
+ Coverage     98.21%   98.21%   +<.01%     
+ Complexity     6199     6197       -2     
============================================
  Files           667      667              
  Lines         44879    44879              
  Branches       6214     6214              
============================================
+ Hits          44076    44078       +2     
+ Misses          258      257       -1     
+ Partials        545      544       -1
Impacted Files Coverage Δ Complexity Δ
...vex/exceptions/OnErrorNotImplementedException.java 100% <100%> (ø) 4 <2> (-1) ⬇️
...o/reactivex/exceptions/UndeliverableException.java 100% <100%> (ø) 1 <1> (ø) ⬇️
...ternal/operators/observable/ObservablePublish.java 96.46% <0%> (-3.54%) 11% <0%> (ø)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 90.82% <0%> (-3.39%) 2% <0%> (ø)
...activex/internal/observers/QueueDrainObserver.java 97.43% <0%> (-2.57%) 21% <0%> (-1%)
...va/io/reactivex/internal/queue/SpscArrayQueue.java 97.61% <0%> (-2.39%) 22% <0%> (-1%)
.../internal/disposables/ListCompositeDisposable.java 98% <0%> (-2%) 34% <0%> (-1%)
...internal/operators/flowable/FlowableSwitchMap.java 95.28% <0%> (-1.42%) 3% <0%> (ø)
...ava/io/reactivex/processors/BehaviorProcessor.java 95.96% <0%> (-0.9%) 59% <0%> (-1%)
.../operators/mixed/FlowableConcatMapCompletable.java 99.14% <0%> (-0.86%) 2% <0%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5445b4a...569a6b3. Read the comment docs.

@@ -48,6 +48,6 @@ public OnErrorNotImplementedException(String message, @NonNull Throwable e) {
* the {@code Throwable} to signal; if null, a NullPointerException is constructed
*/
public OnErrorNotImplementedException(@NonNull Throwable e) {
super(e != null ? e.getMessage() : null, e != null ? e : new NullPointerException());
this("The onError handler in the subscribe() method is not provided. Please specify it to avoid this type of exception. Further reading: https://github.com/ReactiveX/RxJava/blob/2.x/docs/Error-Handling.md | " + (e != null ? e.getMessage() : ""), e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify it to avoid this type of exception.

I'm afraid this advice is too similar to generic error handling like this

try {
  method();
} catch (Throwable t) {
  t.printStackTrace();
}

What about something like:

An error occurred in the flow but no error handler was provided. Further reading: https://github.com/ReactiveX/RxJava/blob/2.x/docs/Error-Handling.md

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"no error handler was provided"

I'm worried users will think having or adding doOnError will solve the error, hence the explicit mention of subscribe().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see

Well, I'm not against mentioning subscribe() as long as we don't just say to "set this error handler to avoid this exception"

We can also mention onErrorXXX, might be a bit overwhelming tho

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this:

The exception was not handled due to missing onError handler in the subscribe() method call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@akarnokd akarnokd merged commit 3e2b1b3 into ReactiveX:2.x Aug 25, 2018
@akarnokd akarnokd deleted the UndeliverableExplanation branch August 25, 2018 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants