Commit 7c73b7ee by Marcin Cieslak

Handle MaybeLocal value from the constructor

In case of exception occuring during construction
of a Sass type instance just return Undefined value,
as the delayed JS exception will pop up later.

The following code:

    var sass = require('./');
        sass.render({
        data: 'div { color: foo(); }',
          functions: {
            'foo()': function() {
              return sass.types.Color(2,3);
            }
          }
    });

now results in an libsass error

     Constructor should be invoked with either 0, 1, 3 or 4 arguments

instead of V8 abort

     FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal
parent 4fa263a0
......@@ -106,8 +106,12 @@ namespace SassTypes
}
} else {
v8::Local<v8::Function> cons = T::get_constructor();
v8::Local<v8::Object> inst = Nan::NewInstance(cons, info.Length(), &localArgs[0]).ToLocalChecked();
v8::Local<v8::Object> inst;
if (Nan::NewInstance(cons, info.Length(), &localArgs[0]).ToLocal(&inst)) {
info.GetReturnValue().Set(inst);
} else {
info.GetReturnValue().Set(Nan::Undefined());
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment