pmed / v8pp

Bind C++ functions and classes into V8 JavaScript engine
http://pmed.github.io/v8pp/
Other
890 stars 120 forks source link

Fixed handling of an exception within a class constructor #99

Open atvise opened 5 years ago

atvise commented 5 years ago

Added try catch within the class wrapobject function to catch possible exceptions from the ctor function

pmed commented 5 years ago

Hi @atvise,

Thanks a lot for the your recent contributions! Excuse me, I really have no spare time to review and merge you pull-request at this time.

The Travis CI build could fail due to old V8 versions. So the pre-requisit will be release v8pp version 1.6 with minimum required V8 version 6.3. After that I think your pull-requests would be merged successfully.

atvise commented 5 years ago

Hi @pmed,

you'r welcome! No problem ;) If you have time again let me know!

pmed commented 5 years ago

Hi,

There is already exception handling in JS constructor function: https://github.com/pmed/v8pp/blob/master/v8pp/class.hpp#L69-L76 that translates std::exception into v8::Exception and returns it as the JS ctor function result.

I've added a couple of checks into the v8pp::class_ test case. These checks work as expected, handling both std::exception, and v8::Exception thrown from the create_X() construction function.