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

Unified Diff: Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.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, 6 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/custom/V8InjectedScriptHostCustom.cpp
diff --git a/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
index 24dd7ba466baecd4f333a263c779a8bda801851d..993a23ef7924f94a2861b15f5f7132618ad05253 100644
--- a/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -330,11 +330,24 @@ void V8InjectedScriptHost::evaluateMethodCustom(const v8::FunctionCallbackInfo<v
ASSERT(isolate->InContext());
v8::TryCatch tryCatch;
v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(expression, info.GetIsolate());
+
+ v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate);
if (tryCatch.HasCaught()) {
- v8SetReturnValue(info, tryCatch.ReThrow());
- return;
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.Exception());
+
+ v8::Local<v8::Object> exceptionDetails = v8::Object::New(isolate);
+ v8::Local<v8::Message> message = tryCatch.Message();
+ 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()));
+ exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), message->GetStackTrace()->AsArray());
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), exceptionDetails);
+ } else {
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result);
+ wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8::Undefined(isolate));
}
- v8SetReturnValue(info, result);
+ v8SetReturnValue(info, wrappedResult);
}
void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
« no previous file with comments | « no previous file | Source/core/inspector/InjectedScriptSource.js » ('j') | Source/core/inspector/InjectedScriptSource.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698