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

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

Issue 369333002: DevTools: Added error message when the command is invoked from the console with exception (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@add-evaluate-exception-details
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/InjectedScriptBase.cpp
diff --git a/Source/core/inspector/InjectedScriptBase.cpp b/Source/core/inspector/InjectedScriptBase.cpp
index 243b0e111caa855d6bfc5a90091eaf26a102aeec..67ef71635bd1860d296b6dd00e0be1336b5f593e 100644
--- a/Source/core/inspector/InjectedScriptBase.cpp
+++ b/Source/core/inspector/InjectedScriptBase.cpp
@@ -39,6 +39,7 @@
#include "platform/JSONValues.h"
#include "wtf/text/WTFString.h"
+using WebCore::TypeBuilder::Array;
using WebCore::TypeBuilder::Runtime::RemoteObject;
namespace WebCore {
@@ -121,7 +122,7 @@ void InjectedScriptBase::makeCall(ScriptFunctionCall& function, RefPtr<JSONValue
}
}
-void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCall& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuilder::OptOutput<bool>* wasThrown)
+void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCall& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuilder::OptOutput<bool>* wasThrown, RefPtr<TypeBuilder::Debugger::ExceptionDetails>* objectExceptionDetails)
{
RefPtr<JSONValue> result;
makeCall(function, &result);
@@ -145,6 +146,52 @@ void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCa
*errorString = "Internal error: result is not a pair of value and wasThrown flag";
return;
}
+ if (wasThrownVal) {
+ RefPtr<JSONObject> exceptionDetails = resultPair->getObject("exceptionDetails");
vsevik 2014/07/15 16:14:33 Let's extract a method.
kozyatinskiy1 2014/07/16 13:15:47 Done.
+ if (objectExceptionDetails && exceptionDetails) {
+ String exceptionDetailsText;
+ if (exceptionDetails->getString("text", &exceptionDetailsText)) {
+ RefPtr<TypeBuilder::Debugger::ExceptionDetails> outputExceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().setText(exceptionDetailsText);
+ String url;
+ if (exceptionDetails->getString("url", &url))
+ outputExceptionDetails->setUrl(url);
+ int line = 0;
+ if (exceptionDetails->getNumber("line", &line))
+ outputExceptionDetails->setLine(line);
+ int column = 0;
+ if (exceptionDetails->getNumber("column", &column))
+ outputExceptionDetails->setColumn(column);
+ RefPtr<JSONArray> stackTrace = exceptionDetails->getArray("stackTrace");
+ if (stackTrace && stackTrace->length() > 0) {
+ RefPtr<TypeBuilder::Array<TypeBuilder::Console::CallFrame> > frames = TypeBuilder::Array<TypeBuilder::Console::CallFrame>::create();
+ for (unsigned i = 0; i < stackTrace->length(); ++i) {
+ RefPtr<JSONObject> stackFrame = stackTrace->get(i)->asObject();
+ int lineNumber = 0;
+ stackFrame->getNumber("lineNumber", &lineNumber);
+ int column = 0;
+ stackFrame->getNumber("column", &column);
+ int scriptId = 0;
+ stackFrame->getNumber("scriptId", &scriptId);
+ String sourceURL;
+ stackFrame->getString("scriptNameOrSourceURL", &sourceURL);
+ String functionName;
+ stackFrame->getString("functionName", &functionName);
+
+ RefPtr<TypeBuilder::Console::CallFrame> callFrame = TypeBuilder::Console::CallFrame::create()
+ .setFunctionName(functionName)
+ .setScriptId(String::number(scriptId))
+ .setUrl(sourceURL)
+ .setLineNumber(lineNumber)
+ .setColumnNumber(column);
+
+ frames->addItem(callFrame);
+ }
+ outputExceptionDetails->setStackTrace(frames);
+ }
+ *objectExceptionDetails = outputExceptionDetails;
+ }
+ }
+ }
*objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj);
*wasThrown = wasThrownVal;
}

Powered by Google App Engine
This is Rietveld 408576698