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

Change onError(Exception) to onError(Throwable) - Issue #296 #315

Merged

Conversation

benjchristensen
Copy link
Member

This changes Observer#onError(Exception e) to Observer#onError(Throwable e)

See "Observer#onError should use Throwable" #296 for discussion that led to this change.

This is a breaking change and will result in a version bump from 0.9.x to 0.10.x.

- Was no longer working once onError(Exception) changed to onError(Throwable) as the assertions throwing java.lang.Error no longer bypassed the composed Observables.
- It was confusing while locally contextual JUnit verifications as used everywhere else are clear, readable and localized to each test
- spying was removed since it wasn't being used and ImmediateScheduler results in no scheduling being done.
See issue "Observer#onError should use Throwable" for background => ReactiveX#296
@cloudbees-pull-request-builder

RxJava-pull-requests #190 SUCCESS
This pull request looks good

* <p>
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/onErrorResumeNext.png">
* <p>
* By default, when an Observable encounters an error that prevents it from emitting the
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps just replace this block with @see onErrorResumeNext? It still refers to the former method rather than onExceptionResumeNext which might be confusing to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

The only part of it that wasn't changed to be specific is the image: onErrorResumeNext.png

I haven't had time to create a new marble diagram but that will come. Most likely @DavidMGross will beat me to it before I get to it.

The rest of the comment is important I feel as it explains the difference from onErrorResumeNext:

... if it encounters an error of type {@link java.lang.Exception}.
This differs from {@link #onErrorResumeNext} in that this one does not handle {@link java.lang.Throwable} or {@link java.lang.Error} but lets those continue through.

@codefromthecrypt
Copy link

diff isn't easy to unveil pitfalls, as catch (Throwable e) diffs don't have a large enough window to show whether or not error propagation occurs after signaling.

Might be worthwhile doing a visual scan via reference check or string search in the ide where catch (Throwable e) to see if errors are propagated after signaling or not. We could possibly assume that a catch (Throwable e) conversion is more likely to imply a change in the next line or two than not... Not sure.

@codefromthecrypt
Copy link

another option would be to make static utility methods like guava's Throwables.propagate and use in common cases such as coercing to Exception, RuntimeException, or propagating errors.

ex.

catch (Throwable e) {
  thingThatTakesException.signal(asException(e));
  propagateIfError(e);
}

@benjchristensen
Copy link
Member Author

@adriancole

diff isn't easy to unveil pitfalls, as catch (Throwable e) diffs don't have a large enough window to show whether or not error propagation occurs after signaling.

This change is very bad for reviewing with a diff that only include a couple lines on either side. When I review the 60+ files before submitting the pull request I had to keep flipping back to the full source code to read the context.

It's just the nature of the change ...

@cloudbees-pull-request-builder

RxJava-pull-requests #191 SUCCESS
This pull request looks good

@benjchristensen
Copy link
Member Author

@adriancole

another option would be to make static utility methods like guava's Throwables.propagate and use in common cases such as coercing to Exception, RuntimeException, or propagating errors.

This already exists in RxJava (Exceptions.propagate(Throwable)), but I just updated it to also throw Error now as I'd missed doing that change last night: benjchristensen@87e308a#L0L25

@cloudbees-pull-request-builder

RxJava-pull-requests #192 SUCCESS
This pull request looks good

@codefromthecrypt
Copy link

Cool sounds like an easy adjustment then!

On Thursday, August 1, 2013, Ben Christensen wrote:

@adriancole https://github.com/adriancole

another option would be to make static utility methods like guava's
Throwables.propagate and use in common cases such as coercing to Exception,
RuntimeException, or propagating errors.

This already exists in RxJava (Exceptions.propagate(Throwable)), but I
just updated it to also throw Error now as I'd missed doing that change
last night: benjchristensen/RxJava@87e308a#L0L25benjchristensen@87e308a#L0L25


Reply to this email directly or view it on GitHubhttps://github.com//pull/315#issuecomment-21952181
.

… test the Throwable catch instead of Exception.
@cloudbees-pull-request-builder

RxJava-pull-requests #193 SUCCESS
This pull request looks good

@benjchristensen
Copy link
Member Author

Moving forward with the merge ...

benjchristensen added a commit that referenced this pull request Aug 1, 2013
Change onError(Exception) to onError(Throwable) - Issue #296
@benjchristensen benjchristensen merged commit 7c5b158 into ReactiveX:master Aug 1, 2013
@benjchristensen benjchristensen deleted the onError-to-throwable branch August 1, 2013 17:25
rickbw pushed a commit to rickbw/RxJava that referenced this pull request Jan 9, 2014
…wable

Change onError(Exception) to onError(Throwable) - Issue ReactiveX#296
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants