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

Unified Diff: Source/core/inspector/JavaScriptCallFrame.cpp

Issue 289423002: DevTools: added injectedScript.evaluateWithDetails, that return exception details if it occured (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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/core/inspector/JavaScriptCallFrame.cpp
diff --git a/Source/core/inspector/JavaScriptCallFrame.cpp b/Source/core/inspector/JavaScriptCallFrame.cpp
index 02abac13c4a97f03976ec1a4269058e5728cea90..d73564949d2dcb8e2b438ec70ab3aaabcc369fc1 100644
--- a/Source/core/inspector/JavaScriptCallFrame.cpp
+++ b/Source/core/inspector/JavaScriptCallFrame.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "core/inspector/JavaScriptCallFrame.h"
+#include "bindings/core/v8/EvaluateExceptionDetailsFactory.h"
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8Binding.h"
#include <v8-debug.h>
@@ -150,7 +151,18 @@ v8::Handle<v8::Value> JavaScriptCallFrame::evaluate(const String& expression)
v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Handle<v8::Function> evalFunction = v8::Handle<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, "evaluate")));
v8::Handle<v8::Value> argv[] = { v8String(m_debuggerContext.newLocal(m_isolate)->GetIsolate(), expression) };
- return evalFunction->Call(callFrame, WTF_ARRAY_LENGTH(argv), argv);
+ v8::TryCatch tryCatch;
+ v8::Handle<v8::Value> result = evalFunction->Call(callFrame, WTF_ARRAY_LENGTH(argv), argv);
+
+ v8::Handle<v8::Object> wrappedResult = v8::Object::New(m_isolate);
+ if (tryCatch.HasCaught()) {
+ wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), tryCatch.Exception());
+ wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails"), createEvaluateExceptionDetails(tryCatch.Message(), m_isolate));
+ } else {
+ wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result);
+ wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails"), v8::Undefined(m_isolate));
+ }
+ return wrappedResult;
}
v8::Handle<v8::Value> JavaScriptCallFrame::restart()

Powered by Google App Engine
This is Rietveld 408576698