// 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_;
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 MessageHandler::ReportMessage(Isolate* isolate,
MessageLocation* loc,
Handle<Object> message) {
- // If we are in process of message reporting, just ignore all other requests
- // to report a message as they are due to unhandled exceptions thrown in
- // message callbacks.
- if (isolate->in_exception_reporting()) {
- PrintF("uncaught exception thrown while reporting\n");
- return;
- }
- isolate->set_in_exception_reporting(true);
-
// We are calling into embedder's code which can throw exceptions.
// Thus we need to save current exception state, reset it to the clean one
// and ignore scheduled exceptions callbacks can throw.
v8::MessageCallback callback =
FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy());
Handle<Object> callback_data(listener.get(1));
- callback(api_message_obj, v8::Utils::ToLocal(callback_data));
+ {
+ // Do not allow exceptions to propagate.
+ v8::TryCatch tryCatch;
+ callback(api_message_obj, v8::Utils::ToLocal(callback_data));
+ }
if (isolate->has_scheduled_exception()) {
isolate->clear_scheduled_exception();
}
}
}
-
- isolate->set_in_exception_reporting(false);
}
int id = Isolate::Current()->thread_manager()->CurrentId();
thread_id_ = (id == 0) ? ThreadManager::kInvalidId : id;
external_caught_exception_ = false;
- in_exception_reporting_ = false;
failed_access_check_callback_ = NULL;
save_context_ = NULL;
catcher_ = NULL;
}
+static int call_depth;
+
+
static void WithTryCatch(Handle<Message> message, Handle<Value> data) {
TryCatch try_catch;
}
static void ThrowFromJS(Handle<Message> message, Handle<Value> data) {
- CompileRun("throw 'ThrowInJS';");
+ if (--call_depth) CompileRun("throw 'ThrowInJS';");
}
static void ThrowViaApi(Handle<Message> message, Handle<Value> data) {
- ThrowException(v8_str("ThrowViaApi"));
+ if (--call_depth) ThrowException(v8_str("ThrowViaApi"));
}
if (callback != NULL) {
V8::AddMessageListener(callback);
}
+ call_depth = 5;
ExpectFalse(
"var thrown = false;\n"
"try { func(); } catch(e) { thrown = true; }\n"