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

Proposal: Consider removing casts to Error when catching #87

Open
PatrickShaw opened this issue Feb 9, 2024 · 0 comments
Open

Proposal: Consider removing casts to Error when catching #87

PatrickShaw opened this issue Feb 9, 2024 · 0 comments

Comments

@PatrickShaw
Copy link

Was investigating this library and found that orWhen accepts an Error. I took a look at the internals of this library and found that there's a cast to Error in

const handled = this.errorFilter(error as Error);

From what I can see there's technically no guarantee that what's being throw is an Error. Someone could, for instance, if they really wanted do, say throw 'some error message' - Not ideal but sometimes we have no control over what's being thrown as the thrown error might live in, say, a third party library.

As such, I propose that we replace the use of Error + the cast to unknown

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

No branches or pull requests

1 participant