Index: src/api.cc |
=================================================================== |
--- src/api.cc (revision 3201) |
+++ src/api.cc (working copy) |
@@ -1197,13 +1197,21 @@ |
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 @@ |
} |
+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. |