Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0044fd2

Browse filesBrowse files
yanivfriedensohntargos
authored andcommitted
src: add error codes to errors thrown in node_i18n.cc
PR-URL: #28221 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 57ac661 commit 0044fd2
Copy full SHA for 0044fd2

File tree

Expand file treeCollapse file tree

2 files changed

+10
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-6
lines changed
Open diff view settings
Collapse file

‎src/node_i18n.cc‎

Copy file name to clipboardExpand all lines: src/node_i18n.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ static void ToUnicode(const FunctionCallbackInfo<Value>& args) {
655655
int32_t len = ToUnicode(&buf, *val, val.length());
656656

657657
if (len < 0) {
658-
return env->ThrowError("Cannot convert name to Unicode");
658+
return THROW_ERR_INVALID_ARG_VALUE(env, "Cannot convert name to Unicode");
659659
}
660660

661661
args.GetReturnValue().Set(
@@ -678,7 +678,7 @@ static void ToASCII(const FunctionCallbackInfo<Value>& args) {
678678
int32_t len = ToASCII(&buf, *val, val.length(), mode);
679679

680680
if (len < 0) {
681-
return env->ThrowError("Cannot convert name to ASCII");
681+
return THROW_ERR_INVALID_ARG_VALUE(env, "Cannot convert name to ASCII");
682682
}
683683

684684
args.GetReturnValue().Set(
Collapse file

‎test/parallel/test-icu-punycode.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-icu-punycode.js
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ const wptToASCIITests = require(
3333
}
3434

3535
{
36-
const errMessage = /^Error: Cannot convert name to ASCII$/;
37-
3836
for (const [i, test] of wptToASCIITests.entries()) {
3937
if (typeof test === 'string')
4038
continue; // skip comments
@@ -43,8 +41,14 @@ const wptToASCIITests = require(
4341
if (comment)
4442
caseComment += ` (${comment})`;
4543
if (output === null) {
46-
assert.throws(() => icu.toASCII(input),
47-
errMessage, `ToASCII ${caseComment}`);
44+
common.expectsError(
45+
() => icu.toASCII(input),
46+
{
47+
code: 'ERR_INVALID_ARG_VALUE',
48+
type: TypeError,
49+
message: 'Cannot convert name to ASCII'
50+
}
51+
);
4852
icu.toASCII(input, true); // Should not throw.
4953
} else {
5054
assert.strictEqual(icu.toASCII(input), output, `ToASCII ${caseComment}`);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.