File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Open diff view settings
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Open diff view settings
Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change @@ -33,8 +33,6 @@ const wptToASCIITests = require(
3333}
3434
3535{
36- const errMessage = / ^ E r r o r : C a n n o t c o n v e r t n a m e t o A S C I I $ / ;
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 } ` ) ;
You can’t perform that action at this time.
0 commit comments