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

Unified Diff: Source/bindings/core/v8/V8Initializer.cpp

Issue 660543002: Fix unhandled promise console message to show stack trace of a DOMException. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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: Source/bindings/core/v8/V8Initializer.cpp
diff --git a/Source/bindings/core/v8/V8Initializer.cpp b/Source/bindings/core/v8/V8Initializer.cpp
index 552f93ef7f021b4fa284135b312a91fe3a6cac7d..e437247438c62e237095e82bc4f6ceb83b9c33bc 100644
--- a/Source/bindings/core/v8/V8Initializer.cpp
+++ b/Source/bindings/core/v8/V8Initializer.cpp
@@ -248,6 +248,17 @@ static void promiseRejectHandlerInMainThread(v8::PromiseRejectMessage message)
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture, isolate);
+ if (!callStack && V8DOMWrapper::isDOMWrapper(message.GetValue())) {
+ // Try to get the stack from a wrapped exception object (e.g. DOMException).
+ v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(message.GetValue());
+ v8::Handle<v8::Value> error = V8HiddenValue::getHiddenValue(isolate, obj, V8HiddenValue::error(isolate));
+ if (!error.IsEmpty()) {
+ stackTrace = v8::Exception::GetStackTrace(error);
+ if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
+ callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture, isolate);
+ }
+ }
+
ScriptState* scriptState = ScriptState::from(context);
promiseRejectMessageQueue().append(PromiseRejectMessage(ScriptValue(scriptState, promise), callStack));
}

Powered by Google App Engine
This is Rietveld 408576698