mapbox/node-cpp-skel

try/catch in HandleOKCallback

開放

#114 建立於 2018年4月4日

 (0 則留言) (0 個反應) (0 位負責人)C++ (9 個分叉)auto 404
good first issue

倉庫指標

星標
 (74 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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:

  • add new code to the HandleOKCallback
  • in many instances that code might throw
  • a throw will not be caught automatically and will instead crash the process with an abort

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.

貢獻者指南