Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
// An error could be an instance of Error while not being a native error
// or could be from a different realm and not be instance of Error but still
// be a native error.
return isNativeError(e) || e instanceof Error;
return Error.isError ? Error.isError(e) : isNativeError(e) || e instanceof Error;

Check failure on line 99 in lib/internal/util.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Use `const { ErrorIsError } = primordials;` instead of the global

Check failure on line 99 in lib/internal/util.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Use `const { ErrorIsError } = primordials;` instead of the global
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we need to ensure backward compatibility?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Error.isError should be the entirety of what isNativeError does, and isNativeError should no longer be needed nor instanceof used.

Wouldn't it make more sense to just remove isError entirely, and use the ErrorIsError primordial directly, and add "don't land" labels on this PR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1, @ljharb

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it! Do you think it is okay to continue with this PR and issue or would it be better to create a new one?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems fine to me to adapt this PR to do that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We still want to match errors that are not regular ones. The wild has many examples of these, so we should keep instanceof.

}

// Keep a list of deprecation codes that have been warned on so we only warn on
Expand Down
Loading