Fix ignored exception thrown from constructor.

This commit is contained in:
Cheng Zhao 2015-01-04 22:13:19 -08:00
parent be2934d9b5
commit 753d5675dd
2 changed files with 22 additions and 2 deletions

View file

@ -156,7 +156,17 @@ class Constructor {
MATE_METHOD_RETURN_UNDEFINED();
}
Wrappable* object = internal::InvokeFactory(args, factory);
Wrappable* object;
{
// Don't continue if the constructor throws an exception.
v8::TryCatch try_catch;
object = internal::InvokeFactory(args, factory);
if (try_catch.HasCaught()) {
try_catch.ReThrow();
MATE_METHOD_RETURN_UNDEFINED();
}
}
if (object)
object->Wrap(isolate, args->GetThis());
else

View file

@ -92,7 +92,17 @@ class Constructor {
MATE_METHOD_RETURN_UNDEFINED();
}
Wrappable* object = internal::InvokeFactory(args, factory);
Wrappable* object;
{
// Don't continue if the constructor throws an exception.
v8::TryCatch try_catch;
object = internal::InvokeFactory(args, factory);
if (try_catch.HasCaught()) {
try_catch.ReThrow();
MATE_METHOD_RETURN_UNDEFINED();
}
}
if (object)
object->Wrap(isolate, args->GetThis());
else