mmomtchev / swig

This is SWIG JavaScript Evolution, a fork of the SWIG project with modern JavaScript/TypeScript support including WASM and async
http://www.swig.org
Other
11 stars 1 forks source link

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

Open mmomtchev opened 4 months ago

mmomtchev commented 4 months ago

https://github.com/mmomtchev/swig/blob/75d9adb183ab375d90b51ab61bd631d442788e23/Doc/Manual/Javascript.html#L1113

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.