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

Not all Errors are equal. #48

Merged
merged 2 commits into from
Aug 10, 2019
Merged

Not all Errors are equal. #48

merged 2 commits into from
Aug 10, 2019

Conversation

agirorn
Copy link
Contributor

@agirorn agirorn commented Apr 24, 2017

Should fix #47

index.js Outdated
@@ -40,6 +40,10 @@ function isBuffer (x) {
return true;
}

function isError (x) {
return x instanceof Error;
Copy link
Member

Choose a reason for hiding this comment

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

The main issue is that this won’t work across realms, and it will fail on an Error that has had its [[Prototype]] changed.

index.js Outdated
@@ -66,6 +70,14 @@ function objEquiv(a, b, opts) {
}
return true;
}
if (isError(a)) {
if (!isError(b)) {
Copy link
Member

Choose a reason for hiding this comment

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

this won’t work right if the first is not an error but the second is

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Rebased on top of #58, and preserved your unique test case.

@ljharb ljharb merged commit c0ae38c into inspect-js:master Aug 10, 2019
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.

Two different Errors are considered equal
4 participants