mapbox / node-cpp-skel

Skeleton for bindings to C++ libraries for Node.js using node-addon-api
Creative Commons Zero v1.0 Universal
72 stars 10 forks source link

try/catch in HandleOKCallback #114

Open springmeyer opened 6 years ago

springmeyer commented 6 years ago

We should add try/catch around code in the HandleOKCallback like https://github.com/mapbox/node-cpp-skel/blob/c3d13e76cfb1178c92bf8beca822da4aba8c28f7/src/object_async/hello_async.cpp#L179-L186. Otherwise down stream developers are likely to:

An example is https://github.com/mapbox/vtquery/issues/69 /cc @mapsam

We must protect against crashes like this, so I think its worth adding try/catch around the code in node-cpp-skel. Then users would be forced (due to the lack of coverage of the catch to think hard about whether an exception is possible.