Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index bde5fdc1a2e0182345cbd7a6c7838e31ae12f695..20edbc5500e92c604414bc3e962b1c765fbe62e8 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -1197,13 +1197,21 @@ v8::TryCatch::TryCatch() |
is_verbose_(false), |
can_continue_(true), |
capture_message_(true), |
+ rethrow_(false), |
js_handler_(NULL) { |
i::Top::RegisterTryCatchHandler(this); |
} |
v8::TryCatch::~TryCatch() { |
- i::Top::UnregisterTryCatchHandler(this); |
+ if (rethrow_) { |
+ v8::HandleScope scope; |
+ v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); |
+ i::Top::UnregisterTryCatchHandler(this); |
+ v8::ThrowException(exc); |
+ } else { |
+ i::Top::UnregisterTryCatchHandler(this); |
+ } |
} |
@@ -1217,6 +1225,13 @@ bool v8::TryCatch::CanContinue() const { |
} |
+v8::Handle<v8::Value> v8::TryCatch::ReThrow() { |
+ if (!HasCaught()) return v8::Local<v8::Value>(); |
+ rethrow_ = true; |
+ return v8::Undefined(); |
+} |
+ |
+ |
v8::Local<Value> v8::TryCatch::Exception() const { |
if (HasCaught()) { |
// Check for out of memory exception. |