Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`JSError.ThrowTypeError` / `ThrowRangeError` / `ThrowSyntaxError` throw a plain `Error`

Đang mở
#509 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@r-Larch đang làm issue này rồi.

Từ ngày 21/10/2026.

  • #511 của @r-Larch — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, node.js
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
789
Fork
81
Merge trung bình
4 ngày 22 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/node-api-dotnet

Tất cả issue của microsoft/node-api-dotnet

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.