`JSError.ThrowTypeError` / `ThrowRangeError` / `ThrowSyntaxError` throw a plain `Error`
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 58/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- C#
- Sterne
- 789
- Forks
- 81
- Ø Merge
- 4 T. 22 Std.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/node-api-dotnet
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microsoft/node-api-dotnet#484 · 1 Kommentar ·
-
`PooledBuffer.FromStringUtf8`/`FromSpanUtf8` never write the NUL terminator → garbage in JS error messages and linked module names on .NETEvtl. vergeben @r-Larch hat das vor 7 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 30/100
microsoft/node-api-dotnet#508 ·
-
JSError.ThrowError(Exception) aborts the process when a Worker terminates during a .NET callEvtl. vergeben @GalaxiasKyklos hat das vor 15 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 18/100
microsoft/node-api-dotnet#505 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 70/100
microsoft/node-api-dotnet#504 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 82/100
microsoft/node-api-dotnet#502 ·
Alle Issues in microsoft/node-api-dotnet
Ähnliche Issues
-
bug 優先: 低
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
-
area-ai bug untriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
dotnet/extensions#7893 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
-
documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100