Fix throwing error in constructor
This commit is contained in:
parent
4a1d11b2be
commit
be2934d9b5
2 changed files with 7 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue