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

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
« no previous file with comments | « Source/core/inspector/InjectedScriptBase.h ('k') | Source/core/inspector/InjectedScriptSource.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InjectedScriptBase.cpp
diff --git a/Source/core/inspector/InjectedScriptBase.cpp b/Source/core/inspector/InjectedScriptBase.cpp
index 243b0e111caa855d6bfc5a90091eaf26a102aeec..a491df74497199eb3830d42629745969730d621d 100644
--- a/Source/core/inspector/InjectedScriptBase.cpp
+++ b/Source/core/inspector/InjectedScriptBase.cpp
@@ -39,10 +39,57 @@
#include "platform/JSONValues.h"
#include "wtf/text/WTFString.h"
+using WebCore::TypeBuilder::Array;
using WebCore::TypeBuilder::Runtime::RemoteObject;
namespace WebCore {
+static PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> toExceptionDetails(PassRefPtr<JSONObject> object)
+{
+ String text;
+ if (!object->getString("text", &text))
+ return nullptr;
+
+ RefPtr<TypeBuilder::Debugger::ExceptionDetails> exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().setText(text);
+ String url;
+ if (object->getString("url", &url))
+ exceptionDetails->setUrl(url);
+ int line = 0;
+ if (object->getNumber("line", &line))
+ exceptionDetails->setLine(line);
+ int column = 0;
+ if (object->getNumber("column", &column))
+ exceptionDetails->setColumn(column);
+ RefPtr<JSONArray> stackTrace = object->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.release());
+ }
+ exceptionDetails->setStackTrace(frames.release());
+ }
+ return exceptionDetails.release();
+}
+
InjectedScriptBase::InjectedScriptBase(const String& name)
: m_name(name)
, m_inspectedStateAccessCheck(0)
@@ -121,7 +168,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>* exceptionDetails)
{
RefPtr<JSONValue> result;
makeCall(function, &result);
@@ -145,6 +192,11 @@ void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCa
*errorString = "Internal error: result is not a pair of value and wasThrown flag";
return;
}
+ if (wasThrownVal) {
+ RefPtr<JSONObject> objectExceptionDetails = resultPair->getObject("exceptionDetails");
+ if (objectExceptionDetails)
+ *exceptionDetails = toExceptionDetails(objectExceptionDetails.release());
+ }
*objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj);
*wasThrown = wasThrownVal;
}
« no previous file with comments | « Source/core/inspector/InjectedScriptBase.h ('k') | Source/core/inspector/InjectedScriptSource.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698