Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index c7bc0741a8b93c59e194360c31945a17fa50c2f1..fb367de4914ca5321613f17cc3319dfaef1d0fb1 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -1851,6 +1851,12 @@ v8::TryCatch::~TryCatch() { |
reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc); |
ASSERT(!isolate_->thread_local_top()->rethrowing_message_); |
} else { |
+ if (HasCaught() && isolate_->has_scheduled_exception()) { |
+ // If an exception was caught but is still scheduled because no API call |
+ // promoted it, then it is canceled to prevent it from being propagated. |
+ // Note that this will not cancel termination exceptions. |
+ isolate_->CancelScheduledExceptionFromTryCatch(this); |
+ } |
isolate_->UnregisterTryCatchHandler(this); |
v8::internal::SimulatorStack::UnregisterCTryCatch(); |
} |