HDF-NI / hdf5.node

A node module for reading/writing the HDF5 file format.
MIT License
123 stars 40 forks source link

Exceptions #74

Closed NINI1988 closed 6 years ago

NINI1988 commented 6 years ago

Fix two errors.

rimmartin commented 6 years ago

I don't think

v8::Isolate::GetCurrent()->ThrowException(
+            v8::Exception::TypeError(String::NewFromUtf8(v8::Isolate::GetCurrent(), ss.str().c_str())));

works from in the FIle::Fie constructor

I'm working on these right now. The other place will probably work

rimmartin commented 6 years ago

I merged the changes from src/methods.cc

NINI1988 commented 6 years ago

ThrowException works for me in the constructor.

rimmartin commented 6 years ago

https://v8docs.nodesource.com/node-8.9/d5/dda/classv8_1_1_isolate.html#af8c2d2fd12d59ddb2c0658f032de4404 only schedules a javascript exception which happens when a return to js happens. That's why in c++ I do a c++ exception which catches back to where ThrowException is scheduled and a return on args is possible:

void File::New(const v8::FunctionCallbackInfo<Value>& args) {

the args that had dropped in from js in the first place.

The derived NodeHDF5::Exception is reliable now