You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSError.ThrowTypeError / ThrowRangeError / ThrowSyntaxError throw a plain Error #509
The string overloads of the typed throw helpers in src/NodeApi/JSError.cs all call JSRuntime.ThrowError:
publicstaticvoidThrowTypeError(stringmessage)=>JSValue.GetCurrentRuntime(outnapi_envenv).ThrowError(env,code:null,message);// should be ThrowTypeError
The same applies to ThrowTypeError(code, message), ThrowRangeError(message), ThrowRangeError(code, message), ThrowSyntaxError(message) and ThrowSyntaxError(code, message). JS therefore receives an Error:
JSRuntime already has ThrowTypeError, ThrowRangeError and ThrowSyntaxError (napi_throw_type_error, napi_throw_range_error, node_api_throw_syntax_error); they just are not called. Fix: call the matching runtime method. I have a PR with a test that checks name, instanceof, message and code for all four error types.
Activity
Throw the named error type from JSError.Throw*Error(string)