`JSError.ThrowTypeError` / `ThrowRangeError` / `ThrowSyntaxError` throw a plain `Error`
评估
调研方向
Start with the string overloads in src/NodeApi/JSError.cs and compare them with the typed throw methods available on JSRuntime. Change each overload to call the matching runtime method. The issue mentions a PR test checking name, instanceof, message and code; use those checks to confirm all four error types behave as expected.
由索引模型根据 Issue 内容生成。
描述
The string overloads of the typed throw helpers in src/NodeApi/JSError.cs all call JSRuntime.ThrowError:
public static void ThrowTypeError(string message)
=> JSValue.GetCurrentRuntime(out napi_env env).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:
try { dotnetCallbackThatCallsThrowTypeError(); }
catch (e) {
e instanceof TypeError; // false
e.name; // '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.
Version: main (54d2b74), 0.9.21 and 0.9.28.
- 主要语言
- C#
- 星标
- 789
- 派生
- 81
- 平均合并
- 4 天 22 小时
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/node-api-dotnet 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
microsoft/node-api-dotnet#484 · 1 条评论 ·
-
`PooledBuffer.FromStringUtf8`/`FromSpanUtf8` never write the NUL terminator → garbage in JS error messages and linked module names on .NET可能已有人在做 @r-Larch 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 30/100
microsoft/node-api-dotnet#508 ·
-
JSError.ThrowError(Exception) aborts the process when a Worker terminates during a .NET call可能已有人在做 @GalaxiasKyklos 于 16 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 18/100
microsoft/node-api-dotnet#505 ·
-
难度 3/5 1-2 天 新手友好度 70/100
microsoft/node-api-dotnet#504 ·
-
难度 3/5 1-2 天 新手友好度 82/100
microsoft/node-api-dotnet#502 ·
查看 microsoft/node-api-dotnet 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug mac アプリ: コード アプリ: チャット 優先: 中 要トリアージ
难度 2/5 1-3 小时 新手友好度 74/100
yksr-melt/Meltype#1346 · 2 条评论 ·
维护者通常 1 天内回复
-
Collect corrected translations in the app, with no GitHub account and the least possible friction未关闭localization medium ui
难度 2/5 1-3 小时 新手友好度 65/100
hexide-io/HexIDE#2819 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100