Lets say I have a JS function which is simply throwing an error:
function() { throw "Danger, Will Robinson!"; }
This function passed in as an argument to a node.js addon and is used to construct a Nan::Callback (which should take care of making this handle persistent):
// get handle to JS function and its Tcl name
Handle<Function> fun = Handle<Function>::Cast( info[0] );
Nan::Callback *pf = new Nan::Callback(fun);
I'm having problems intercepting this JS exception from C++ when the Nan::Callback
is called with Call()
from C++:
Nan::TryCatch tc;
Local<Value> retv = pf->Call( Nan::GetCurrentContext()->Global(), objc-1, &args );
if ( tc.HasCaught() ) {
printf("EXCEPTION:\n");
...
In fact the script simply exits at the JS error and I never get back to inspect tc
and the calls return value (retv
) for any pending exceptions. What am I doing wrong?