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

refactor(ext/node): align error messages #25917

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

irbull
Copy link
Contributor

@irbull irbull commented Sep 27, 2024

Aligns the error messages in the ext/node folder to be in-line with the Deno style guide.

#25269

Aligns the error messages in the ext/node folder to be in-line with the
Deno style guide.

denoland#25269
@@ -42,7 42,7 @@ export function writeFile(
optOrCallback instanceof Function ? undefined : optOrCallback;

if (!callbackFn) {
throw new TypeError("Callback must be a function.");
throw new TypeError("Callback must be a function");
Copy link
Member

Choose a reason for hiding this comment

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

This change is nice, but one thing about ext/node is probably the error messages should align with whatever node does for better compability? By doing this are we making the compatiblity worse or are these error messages already not aligned with node?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. It seems they are not the same either way:

fs.writeFile('/Users/irbull/test.txt', content, undefined, undefined);

In node (v21.6.2) I get:

TypeError [ERR_INVALID_ARG_TYPE]: The "cb" argument must be of type function. Received undefined

In Deno (1.46.3) I get:

TypeError: Callback must be a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to pump the brakes on the node compat stuff. I don't know if we should consider the error messages part of the API surface. It seems like it might have to be, but then we should align with what Node does. That would be a pretty big undertaking. Have you seen reports of inconsistencies causing problems?

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