How to throw the exception and catch it in the Node.js?
I am writing an ADD-ON using C/C++ in Node.js. For some reason, I need to
throw the exception in C/C++ Add-on side, and to catch the exception in
the JavaScript side.
JavaScript side:
try {
var conn = addon.get();
} catch(e) {
console.log("catching....................");
}
C/C++ code:
if (args.Length() <= 1 && !args[1]->IsFunction()) {
ThrowException(Exception::TypeError(String::New("Arguments 1 expect a
function!"))); }
The actual behavior is: For WIN: A dialog pop-ups and shows:
Microsoft Visual C++ Runtime Library
Assertion failed!
Program: ...verMananger\src\wrapper\build\Release\nodedb2.node File:
c:\users\ibm_admin.node-gyp\0.10.1...\node_ob..._wrap.h Line: 60
Expression: !handle.IsEmpty()
For information on how your program can cause an assertion failure, see
the Visual C++ documentation on asserts
(Press Retry to debug the application - JIT must be enabled)
Abort Retry Ignore
For Linux:
node: /root/.node-gyp/0.10.9/src/node_object_wrap.h:60: static T*
node::ObjectWrap::Unwrap(v8::Handle) [with T = NodeDB2Connection]:
Assertion `!handle.IsEmpty()' failed.
How to throw the exception and catch it in the Node.js? Did everybody meet
the same problem as I met?
No comments:
Post a Comment