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

Consider using SuppressedError when invoking a callback in error steps #177

Open
domfarolino opened this issue Sep 22, 2024 · 1 comment
Labels
possible future enhancement An enhancement that doesn't block standardization or shipping

Comments

@domfarolino
Copy link
Collaborator

The catch() and inspect() operators have internal observers whose error steps invoke a developer-supplied callback with the given error value they receive. If that callback throws an error, then we must invoke Subscriber's error() method with the error thrown from the callback instead of the original error they intended to surface. This clobbering of the original error is exactly what SuppressedError intends to alleviate (first mentioned in #174), so we should consider using it in those operators.

@domfarolino domfarolino added the possible future enhancement An enhancement that doesn't block standardization or shipping label Sep 22, 2024
@Jamesernator
Copy link
Contributor

So this probably shouldn't be done for .catch as it's reasonable that a catch may already be replacing/wrapping the given error with a new error.

I'm now mixed whether it's even worth doing for .inspect given that there is opportunity to react to the given error, though it does seem more reasonable there as an error thrown from .inspect is probably a mistake in most cases.

There is actually one place in .catch though where the error is swallowed, and that's if the return value of the callback fails to be converted to observable:

obs.catch((error) => {
    // We can't catch the error from Observable.from
    return null;
});

so it might be worth doing a SuppressedError here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible future enhancement An enhancement that doesn't block standardization or shipping
Projects
None yet
Development

No branches or pull requests

2 participants