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): align error messages #25914

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 5 additions & 3 deletions ext/net/02_tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,19 @@ function loadTlsKeyPair(api, {

// Check for "pem" format
if (keyFormat !== undefined && keyFormat !== "pem") {
throw new TypeError('If `keyFormat` is specified, it must be "pem"');
throw new TypeError(
`If "keyFormat" is specified, it must be "pem": received "${keyFormat}"`,
);
}

if (cert !== undefined && key === undefined) {
throw new TypeError(
`If \`cert\` is specified, \`key\` must be specified as well for \`${api}\`.`,
`If \`cert\` is specified, \`key\` must be specified as well for \`${api}\``,
Copy link
Member

Choose a reason for hiding this comment

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

We're using double quotes for option KeyFormat, but using backquotes for cert. Should we make them consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. We didn't really specify which quoting style we want and things are all over the map. I've been trying to remove the forward tick style as that wasn't used much. I've been trying to align on double quotes, but I know that it's a bit of a mixed bag.

I guess this particular rule could be specified with a linter rule, but that would likely cause the entire code base to fail and would require a rather large change-set to align everything. I'm not sure that's worth it.

That's a long way of saying I'll move to double quotes here, and if we want to align the entire code base we can file an issue and weigh the benefits.

);
}
if (cert === undefined && key !== undefined) {
throw new TypeError(
`If \`key\` is specified, \`cert\` must be specified as well for \`${api}\`.`,
`If \`key\` is specified, \`cert\` must be specified as well for \`${api}\``,
);
}

Expand Down
2 changes: 1 addition & 1 deletion ext/url/00_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class URLSearchParams {
throw new TypeError(
`${prefix}: Item ${
i + 0
} in the parameter list does have length 2 exactly.`,
} in the parameter list does have length 2 exactly`,
);
}
return [pair[0], pair[1]];
Expand Down