-
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
RxJava 2.0.6 : New undeliverable error handling #5099
Comments
Sorry, while reading my post I saw its just stated about |
The intent was to have |
So you think it is best practice to re-throw the error if it's an RxJavaPlugins.setErrorHandler(throwable -> {
if (throwable instanceof OnErrorNotImplementedException || throwable instanceof ProtocolViolationException) {
throw new RuntimeExecutionException(throwable);
}
Timber.e(throwable, "Error handler reported");
}); If so it might make sense to write that in the wiki as it seems mandatory to add the handler that way if I understand correctly. |
Don't rethrow and let the app crash. On Android, you can call |
RxJavaPlugins.setErrorHandler(throwable -> {
if (throwable instanceof OnErrorNotImplementedException || throwable instanceof ProtocolViolationException) {
Thread currentThread = Thread.currentThread();
currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, throwable);
}
}); So this is equivalent to the RxJava 1 behavior? |
RxJava 1 by default didn't call |
I got burned by this again. I caused a NPE when touching an object in How can I handle errors correctly with RxJava? When I'm just reporting the uncaught exception, my app crashes in circumstances where it should not crash. |
Sounds like you have to do more parameter validation. There exist a |
I find it really confusing and got burned again. Maybe you can add an entry in the wiki what a good error handling for android looks like? For example this: Single.timer(2, TimeUnit.SECONDS)
.subscribe(__ -> {
throw new RuntimeException();
}); Why does this get wrapped as an |
The wiki has been updated a couple of days ago. That is supposed to signal an |
So should I report it as a bug? Here is a faililng test case: @Test
fun testThrowsOnErrorNotImplemented() {
RxJavaPlugins.setErrorHandler {
check(it is OnErrorNotImplementedException)
}
Single.just(0).subscribe { _ -> throw RuntimeException() }
} (it fails because it's an |
No need. I overlooked |
And why not? And why can completable and observable do so? |
CallbackCompletableObserver calls @Override
public void onComplete() {
try {
onComplete.run();
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
onError(ex);
return;
}
lazySet(DisposableHelper.DISPOSED);
} But ConsumerSingleObserver calls @Override
public void onSuccess(T value) {
try {
onSuccess.accept(value);
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
RxJavaPlugins.onError(ex);
}
} So Completable delegates to onError and Singlet to the plugin? Can't it just call its own onError too? |
Looks like a bug in the completable handler since that violates the contract. |
Indeed, that looks like a copy-paste error. |
|
Looks like this question has been answered. If you have further input on the issue, don't hesitate to reopen this issue or post a new one. |
In the release docs of 2.0.6 it is stated that
What is the reason for that?
Also I cannot confirm this behaivor. If I understand correctly
This should not be wrapped and thus not be re-thrown. But it is.
The text was updated successfully, but these errors were encountered: