diff --git a/native_mate/constructor.h b/native_mate/constructor.h index 16cec447d2a7..3d2ed69c0eab 100644 --- a/native_mate/constructor.h +++ b/native_mate/constructor.h @@ -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(); } diff --git a/native_mate/constructor.h.pump b/native_mate/constructor.h.pump index 81a7524087e6..a0ef452fde0f 100644 --- a/native_mate/constructor.h.pump +++ b/native_mate/constructor.h.pump @@ -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());