You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the recommended method to handle C++ exceptions:
%module napi_stack_traces
// This test works only with NAPI
%include "exception.i"
%exception {
try {
$action
} catch (const std::exception &e) {
SWIG_Raise(e.what());
SWIG_fail;
}
}
%inline %{
voidthrows() {
throw std::logic_error{"error with stack"};
}
%}
constnapi_stack_traces=require('napi_stack_traces');asyncfunctionmustBeOnStack2(){try{awaitnapi_stack_traces.throws();console.error('throws() did not throw');process.exit(1);}catch(e){console.log('error',e,typeofe,e.constructor,e.stack)if(!e.stack.match(/mustBeOnStack1/))thrownewError('mustBeOnStack1 not on stack');if(!e.stack.match(/mustBeOnStack2/))thrownewError('mustBeOnStack2 not on stack');}}functionmustBeOnStack1(){returnmustBeOnStack2();}mustBeOnStack1();
The stack trace is not preserved:
error [Error: error with stack] object [Function: Error] { stackTraceLimit: 10 } Error: error with stack
file:///home/mmom/src/swig/Examples/test-suite/javascript/napi_stack_traces_async_runme.mjs:12
throw new Error('mustBeOnStack1 not on stack');
^
Error: mustBeOnStack1 not on stack
at mustBeOnStack2 (file:///home/mmom/src/swig/Examples/test-suite/javascript/napi_stack_traces_async_runme.mjs:12:13)
The text was updated successfully, but these errors were encountered:
Ideally, this should be solved directly in Node-API in napi_create_promise and napi_reject_deferred, but alas, given the ongoing affair, I am still blocked from doing anything in Node.js
When using the recommended method to handle C++ exceptions:
The stack trace is not preserved:
The text was updated successfully, but these errors were encountered: