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

Side by Side Diff: chrome/renderer/module_system.cc

Issue 10900013: Merge 153283 - Make ModuleSystem::DumpException() handle empty handles. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1229/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/module_system.h" 5 #include "chrome/renderer/module_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup pression.h" 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup pression.h"
9 9
10 namespace { 10 namespace {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 // static 62 // static
63 void ModuleSystem::DumpException(const v8::TryCatch& try_catch) { 63 void ModuleSystem::DumpException(const v8::TryCatch& try_catch) {
64 v8::Handle<v8::Message> message(try_catch.Message()); 64 v8::Handle<v8::Message> message(try_catch.Message());
65 if (message.IsEmpty()) { 65 if (message.IsEmpty()) {
66 LOG(ERROR) << "try_catch has no message"; 66 LOG(ERROR) << "try_catch has no message";
67 return; 67 return;
68 } 68 }
69 69
70 LOG(ERROR) << "[" 70 std::string resource_name = "<unknown resource>";
71 << *v8::String::Utf8Value( 71 if (!message->GetScriptResourceName().IsEmpty()) {
72 message->GetScriptResourceName()->ToString()) 72 resource_name = *v8::String::Utf8Value(
73 << "(" << message->GetLineNumber() << ")] " 73 message->GetScriptResourceName()->ToString());
74 << *v8::String::Utf8Value(message->Get()) 74 }
75 << "{" << *v8::String::Utf8Value(try_catch.StackTrace()) << "}"; 75
76 std::string error_message = "<no error message>";
77 if (!message->Get().IsEmpty())
78 error_message = *v8::String::Utf8Value(message->Get());
79
80 std::string stack_trace = "<stack trace unavailable>";
81 if (!try_catch.StackTrace().IsEmpty())
82 stack_trace = *v8::String::Utf8Value(try_catch.StackTrace());
83
84 LOG(ERROR) << "[" << resource_name << "(" << message->GetLineNumber() << ")] "
85 << error_message
86 << "{" << stack_trace << "}";
76 } 87 }
77 88
78 void ModuleSystem::Require(const std::string& module_name) { 89 void ModuleSystem::Require(const std::string& module_name) {
79 v8::HandleScope handle_scope; 90 v8::HandleScope handle_scope;
80 RequireForJsInner(v8::String::New(module_name.c_str())); 91 RequireForJsInner(v8::String::New(module_name.c_str()));
81 } 92 }
82 93
83 v8::Handle<v8::Value> ModuleSystem::RequireForJs(const v8::Arguments& args) { 94 v8::Handle<v8::Value> ModuleSystem::RequireForJs(const v8::Arguments& args) {
84 v8::HandleScope handle_scope; 95 v8::HandleScope handle_scope;
85 v8::Handle<v8::String> module_name = args[0]->ToString(); 96 v8::Handle<v8::String> module_name = args[0]->ToString();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 v8::Handle<v8::String> left = 251 v8::Handle<v8::String> left =
241 v8::String::New("(function(require, requireNative, exports) {"); 252 v8::String::New("(function(require, requireNative, exports) {");
242 v8::Handle<v8::String> right = v8::String::New("\n})"); 253 v8::Handle<v8::String> right = v8::String::New("\n})");
243 return handle_scope.Close( 254 return handle_scope.Close(
244 v8::String::Concat(left, v8::String::Concat(source, right))); 255 v8::String::Concat(left, v8::String::Concat(source, right)));
245 } 256 }
246 257
247 v8::Handle<v8::Value> ModuleSystem::ThrowException(const std::string& message) { 258 v8::Handle<v8::Value> ModuleSystem::ThrowException(const std::string& message) {
248 return v8::ThrowException(v8::String::New(message.c_str())); 259 return v8::ThrowException(v8::String::New(message.c_str()));
249 } 260 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698