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

Side by Side 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: Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 // Copyright 2006-2008 the V8 project authors. All rights reserved. 2 // Copyright 2006-2008 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 void MessageHandler::ReportMessage(MessageLocation* loc, 129 void MessageHandler::ReportMessage(MessageLocation* loc,
130 Handle<Object> message) { 130 Handle<Object> message) {
131 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); 131 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message);
132 132
133 v8::NeanderArray global_listeners(Factory::message_listeners()); 133 v8::NeanderArray global_listeners(Factory::message_listeners());
134 int global_length = global_listeners.length(); 134 int global_length = global_listeners.length();
135 if (global_length == 0) { 135 if (global_length == 0) {
136 DefaultMessageReport(loc, message); 136 DefaultMessageReport(loc, message);
137 } else { 137 } else {
138 // We are calling into embedder's code. Clean pending exception
139 // and ignore scheduled exceptions the callback can throw.
140 Top::clear_pending_exception();
Mads Ager (chromium) 2011/01/28 11:39:18 Should this be moved to the caller? I think we onl
antonm 2011/01/28 13:37:25 Let me try modified second approach: I'll move all
138 for (int i = 0; i < global_length; i++) { 141 for (int i = 0; i < global_length; i++) {
139 HandleScope scope; 142 HandleScope scope;
140 if (global_listeners.get(i)->IsUndefined()) continue; 143 if (global_listeners.get(i)->IsUndefined()) continue;
141 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); 144 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i)));
142 Handle<Proxy> callback_obj(Proxy::cast(listener.get(0))); 145 Handle<Proxy> callback_obj(Proxy::cast(listener.get(0)));
143 v8::MessageCallback callback = 146 v8::MessageCallback callback =
144 FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy()); 147 FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy());
145 Handle<Object> callback_data(listener.get(1)); 148 Handle<Object> callback_data(listener.get(1));
146 callback(api_message_obj, v8::Utils::ToLocal(callback_data)); 149 callback(api_message_obj, v8::Utils::ToLocal(callback_data));
150 if (Top::has_scheduled_exception()) {
151 // Consider logging it somehow.
Vitaly Repeshko 2011/01/28 14:03:33 What if we get an OOM or termination exception her
antonm 2011/01/28 14:43:18 That sounds like a very good point. I think we sh
152 Top::clear_scheduled_exception();
153 }
147 } 154 }
148 } 155 }
149 } 156 }
150 157
151 158
152 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { 159 Handle<String> MessageHandler::GetMessage(Handle<Object> data) {
153 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); 160 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage");
154 Handle<JSFunction> fun = 161 Handle<JSFunction> fun =
155 Handle<JSFunction>(JSFunction::cast( 162 Handle<JSFunction>(JSFunction::cast(
156 Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str))); 163 Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str)));
(...skipping 17 matching lines...) Expand all
174 } 181 }
175 182
176 183
177 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { 184 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) {
178 HandleScope scope; 185 HandleScope scope;
179 return GetMessage(data)->ToCString(DISALLOW_NULLS); 186 return GetMessage(data)->ToCString(DISALLOW_NULLS);
180 } 187 }
181 188
182 189
183 } } // namespace v8::internal 190 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698