Skip to content
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

Comply with the Node.js convention that asynchronous functions should never throw synchronous exceptions #54

Open
mmomtchev opened this issue May 24, 2024 · 0 comments

Comments

@mmomtchev
Copy link
Owner

<p>The usual Node.js convention is that functions that return a <code>Promise</code> should never throw synchronously, because this forces the end user to catch eventual errors in two distrinct ways. Throwing a C++ exception in a wrapped function will automatically result in a rejected <code>Promise</code>.</p>

Currently an asynchronous wrapper will throw synchronously if it fails to parse the Javascript arguments.

It will still reject the asynchronous Promise if the underlying C/C++ method throws or if one of the check typemap fails.

This is in contrast to the usual Node.js convention that a function that returns a Promise should never throw as this forces the caller to implement two error-checking semantics.

Implementing this requires a complete overhaul of the overloading resolution and implementing typecheck typemaps which are still not supported in Javascript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant