Skip to content

[Question] Is it by designed that only Napi::Error can be thrown? #1656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neko-para opened this issue Apr 26, 2025 · 1 comment
Closed

[Question] Is it by designed that only Napi::Error can be thrown? #1656

neko-para opened this issue Apr 26, 2025 · 1 comment

Comments

@neko-para
Copy link
Contributor

It seems that currently only Napi::Error have the method ThrowAsJavaScriptException, while the underlying function napi_throw accepts any kinds of value. I've managed to throw an number via napi_throw.

@mhdawson
Copy link
Member

mhdawson commented May 2, 2025

From our discussion in the node-api team meeting, our current thinking is that is is best practice to through Errors, not some arbritray object.

So I would say it is by design as we don't want to encourage something other than best practice.

@github-project-automation github-project-automation bot moved this from Need Triage to Done in Node-API Team Project May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants