Fix throwing error in constructor

This commit is contained in:
Cheng Zhao 2015-01-02 18:04:46 -08:00
parent 4a1d11b2be
commit be2934d9b5
2 changed files with 7 additions and 0 deletions

View file

@ -159,6 +159,8 @@ class Constructor {
Wrappable* object = internal::InvokeFactory(args, factory);
if (object)
object->Wrap(isolate, args->GetThis());
else
args->ThrowError();
MATE_METHOD_RETURN_UNDEFINED();
}

View file

@ -87,6 +87,11 @@ class Constructor {
private:
static MATE_METHOD_RETURN_TYPE New(const WrappableFactoryFunction& factory,
v8::Isolate* isolate, Arguments* args) {
if (!args->IsConstructCall()) {
args->ThrowError("Requires constructor call");
MATE_METHOD_RETURN_UNDEFINED();
}
Wrappable* object = internal::InvokeFactory(args, factory);
if (object)
object->Wrap(isolate, args->GetThis());