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

fix: simplify error class checking #53

Merged
merged 1 commit into from
May 8, 2024
Merged

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented May 8, 2024

Previously, we were unnecessarily trying to determine if the passed object was in fact a class which extends Error.

We don't actually care about this, really. We just want to know if the thrown is an instance of the thing you passed.

Due to this, we can simplify by simply checking that the errorLike is something with a prototype and assert that the thrown is an instance of it.

cc @koddsson - i broke the last release because of this. so would be good to get the fix out. i tested it against chai already and all seems well, but please double check my logic here 👀

Previously, we were unnecessarily trying to determine if the passed
object was in fact a class which extends `Error`.

We don't actually care about this, really. We just want to know if the
`thrown` is an instance of the thing you passed.

Due to this, we can simplify by simply checking that the `errorLike` is
something with a `prototype` and assert that the `thrown` is an instance
of it.
Copy link
Member

@koddsson koddsson left a comment

Choose a reason for hiding this comment

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

Looks good :)

@koddsson koddsson merged commit 36f9271 into chaijs:main May 8, 2024
1 check passed
@43081j 43081j deleted the class-nonsense branch May 9, 2024 07:23
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.

2 participants