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

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
« no previous file with comments | « Source/core/inspector/JavaScriptCallFrame.h ('k') | Source/core/inspector/JavaScriptCallFrame.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/JavaScriptCallFrame.cpp
diff --git a/Source/core/inspector/JavaScriptCallFrame.cpp b/Source/core/inspector/JavaScriptCallFrame.cpp
index f01ce098d5c721aa88e782153cacc0d5e3174fa6..821adf0e414a0b0e369dc12d96b976d44279f344 100644
--- a/Source/core/inspector/JavaScriptCallFrame.cpp
+++ b/Source/core/inspector/JavaScriptCallFrame.cpp
@@ -150,12 +150,23 @@ v8::Handle<v8::Value> JavaScriptCallFrame::returnValue() const
return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "returnValue"));
}
-v8::Handle<v8::Value> JavaScriptCallFrame::evaluate(const String& expression)
+v8::Handle<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(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"), createExceptionDetails(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()
@@ -181,6 +192,20 @@ ScriptValue JavaScriptCallFrame::setVariableValue(ScriptState* scriptState, int
return ScriptValue(scriptState, setVariableValueFunction->Call(callFrame, WTF_ARRAY_LENGTH(argv), argv));
}
+v8::Handle<v8::Object> JavaScriptCallFrame::createExceptionDetails(v8::Handle<v8::Message> message, v8::Isolate* isolate)
+{
+ v8::Handle<v8::Object> exceptionDetails = v8::Object::New(isolate);
+ exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "text"), message->Get());
+ exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "url"), message->GetScriptOrigin().ResourceName());
+ exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Integer::New(isolate, message->GetLineNumber()));
+ exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::Integer::New(isolate, message->GetStartColumn()));
+ if (!message->GetStackTrace().IsEmpty())
+ exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), message->GetStackTrace()->AsArray());
+ else
+ exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8::Undefined(isolate));
+ return exceptionDetails;
+}
+
void JavaScriptCallFrame::trace(Visitor* visitor)
{
visitor->trace(m_caller);
« no previous file with comments | « Source/core/inspector/JavaScriptCallFrame.h ('k') | Source/core/inspector/JavaScriptCallFrame.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698