Index: src/isolate.h |
diff --git a/src/isolate.h b/src/isolate.h |
index 13ffc1353b4bd34b94526686ec1b34c7ef2f64ca..61f180ea244b4a906c01ea78ae4695dca528a532 100644 |
--- a/src/isolate.h |
+++ b/src/isolate.h |
@@ -187,6 +187,9 @@ class ThreadLocalTop BASE_EMBEDDED { |
// unify them later. |
MaybeObject* scheduled_exception_; |
bool external_caught_exception_; |
+ // True if unhandled message is being currently reported by |
+ // MessageHandler::ReportMessage. |
+ bool in_exception_reporting_; |
SaveContext* save_context_; |
v8::TryCatch* catcher_; |
@@ -490,6 +493,9 @@ class Isolate { |
bool external_caught_exception() { |
return thread_local_top_.external_caught_exception_; |
} |
+ void set_external_caught_exception(bool value) { |
+ thread_local_top_.external_caught_exception_ = value; |
+ } |
void set_pending_exception(MaybeObject* exception) { |
thread_local_top_.pending_exception_ = exception; |
} |
@@ -517,6 +523,18 @@ class Isolate { |
bool* external_caught_exception_address() { |
return &thread_local_top_.external_caught_exception_; |
} |
+ bool in_exception_reporting() { |
+ return thread_local_top_.in_exception_reporting_; |
+ } |
+ void set_in_exception_reporting(bool value) { |
+ thread_local_top_.in_exception_reporting_ = value; |
+ } |
+ v8::TryCatch* catcher() { |
+ return thread_local_top_.catcher_; |
+ } |
+ void set_catcher(v8::TryCatch* catcher) { |
+ thread_local_top_.catcher_ = catcher; |
+ } |
MaybeObject** scheduled_exception_address() { |
return &thread_local_top_.scheduled_exception_; |
@@ -587,6 +605,27 @@ class Isolate { |
// JavaScript code. If an exception is scheduled true is returned. |
bool OptionalRescheduleException(bool is_bottom_call); |
+ class ExceptionScope { |
+ public: |
+ explicit ExceptionScope(Isolate* isolate) : |
+ // Scope currently can only be used for regular exceptions, not |
+ // failures like OOM or termination exception. |
+ isolate_(isolate), |
+ pending_exception_(isolate_->pending_exception()->ToObjectUnchecked()), |
+ catcher_(isolate_->catcher()) |
+ { } |
+ |
+ ~ExceptionScope() { |
+ isolate_->set_catcher(catcher_); |
+ isolate_->set_pending_exception(*pending_exception_); |
+ } |
+ |
+ private: |
+ Isolate* isolate_; |
+ Handle<Object> pending_exception_; |
+ v8::TryCatch* catcher_; |
+ }; |
+ |
void SetCaptureStackTraceForUncaughtExceptions( |
bool capture, |
int frame_limit, |
@@ -1015,6 +1054,8 @@ class Isolate { |
void FillCache(); |
+ void PropagatePendingExceptionToExternalTryCatch(); |
+ |
int stack_trace_nesting_level_; |
StringStream* incomplete_message_; |
// The preallocated memory thread singleton. |