Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1301)

Unified Diff: src/messages.cc

Issue 6397011: Make exception thrown via v8 public API propagate to v8::TryCatch as JS thrown exceptions do. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing Vitaly's comments Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/messages.cc
diff --git a/src/messages.cc b/src/messages.cc
index 42fc3c9bd66fdd2742983340db3b41b0ad158114..a85c16baad29355c042da76aeff82ee432e7defe 100644
--- a/src/messages.cc
+++ b/src/messages.cc
@@ -128,12 +128,23 @@ Handle<Object> MessageHandler::MakeMessageObject(
void MessageHandler::ReportMessage(MessageLocation* loc,
Handle<Object> message) {
+ // 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.
+ Top::Scope top_scope;
Vitaly Repeshko 2011/02/01 19:07:17 I don't like the name. ExceptionScope? Also given
antonm 2011/02/01 20:14:39 Renamed to ExceptionScope.
+ Top::clear_pending_exception();
+ Top::set_external_caught_exception(false);
+
v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message);
v8::NeanderArray global_listeners(Factory::message_listeners());
int global_length = global_listeners.length();
if (global_length == 0) {
DefaultMessageReport(loc, message);
+ if (Top::has_scheduled_exception()) {
+ // Consider logging it somehow.
Vitaly Repeshko 2011/02/01 19:07:17 Please file a bug to not forget about "scary" exce
antonm 2011/02/01 20:14:39 Will do.
+ Top::clear_scheduled_exception();
+ }
} else {
for (int i = 0; i < global_length; i++) {
HandleScope scope;
@@ -144,6 +155,10 @@ void MessageHandler::ReportMessage(MessageLocation* loc,
FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy());
Handle<Object> callback_data(listener.get(1));
callback(api_message_obj, v8::Utils::ToLocal(callback_data));
+ if (Top::has_scheduled_exception()) {
+ // Consider logging it somehow.
+ Top::clear_scheduled_exception();
+ }
}
}
}

Powered by Google App Engine
This is Rietveld 408576698