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

Unified Diff: Source/devtools/front_end/sdk/ScriptSnippetModel.js

Issue 290633009: DevTools: Show detailed information for exceptions during snippet execution. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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/devtools/front_end/sdk/ScriptSnippetModel.js
diff --git a/Source/devtools/front_end/sdk/ScriptSnippetModel.js b/Source/devtools/front_end/sdk/ScriptSnippetModel.js
index 450f1515be66d381f4bbfd268408975462c3b2c5..d6de822e61fb55b146cd1239ce26f063a1779be3 100644
--- a/Source/devtools/front_end/sdk/ScriptSnippetModel.js
+++ b/Source/devtools/front_end/sdk/ScriptSnippetModel.js
@@ -221,11 +221,11 @@ WebInspector.ScriptSnippetModel.prototype = {
/**
* @param {!WebInspector.Target} target
* @param {?string} error
- * @param {string=} scriptId
- * @param {string=} syntaxErrorMessage
+ * @param {!DebuggerAgent.ScriptId=} scriptId
+ * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
* @this {WebInspector.ScriptSnippetModel}
*/
- function compileCallback(target, error, scriptId, syntaxErrorMessage, lineNumber, columnNumber)
+ function compileCallback(target, error, scriptId, exceptionDetails)
{
if (!uiSourceCode || uiSourceCode._evaluationIndex !== evaluationIndex)
return;
@@ -236,16 +236,7 @@ WebInspector.ScriptSnippetModel.prototype = {
}
if (!scriptId) {
- var consoleMessage = new WebInspector.ConsoleMessage(
- target,
- WebInspector.ConsoleMessage.MessageSource.JS,
- WebInspector.ConsoleMessage.MessageLevel.Error,
- syntaxErrorMessage || "",
- undefined,
- evaluationUrl,
- lineNumber,
- columnNumber);
- target.consoleModel.addMessage(consoleMessage);
+ this._printRunOrCompileScriptResultFailure(target, exceptionDetails, evaluationUrl);
return;
}
@@ -262,7 +253,6 @@ WebInspector.ScriptSnippetModel.prototype = {
*/
_runScript: function(scriptId, executionContext, sourceURL)
{
- console.error(executionContext);
var target = executionContext.target();
target.debuggerAgent().runScript(scriptId, executionContext.id, "console", false, runCallback.bind(this, target));
@@ -270,39 +260,66 @@ WebInspector.ScriptSnippetModel.prototype = {
* @param {!WebInspector.Target} target
* @param {?string} error
* @param {?RuntimeAgent.RemoteObject} result
- * @param {boolean=} wasThrown
+ * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
* @this {WebInspector.ScriptSnippetModel}
*/
- function runCallback(target, error, result, wasThrown, lineNumber, columnNumber)
+ function runCallback(target, error, result, exceptionDetails)
{
if (error) {
console.error(error);
return;
}
- this._printRunScriptResult(target, result, wasThrown, sourceURL, lineNumber, columnNumber);
+ var wasThrown = !!exceptionDetails;
+ if (!wasThrown)
+ this._printRunScriptResult(target, result, sourceURL);
+ else
+ this._printRunOrCompileScriptResultFailure(target, exceptionDetails, sourceURL);
}
},
/**
* @param {!WebInspector.Target} target
* @param {?RuntimeAgent.RemoteObject} result
- * @param {boolean=} wasThrown
+ * @param {?string=} sourceURL
*/
- _printRunScriptResult: function(target, result, wasThrown, sourceURL, lineNumber, columnNumber)
+ _printRunScriptResult: function(target, result, sourceURL)
{
- var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log);
- var message = new WebInspector.ConsoleMessage(target,
+ var consoleMessage = new WebInspector.ConsoleMessage(
+ target,
WebInspector.ConsoleMessage.MessageSource.JS,
- level,
- (wasThrown ? result.description : ""),
+ WebInspector.ConsoleMessage.MessageLevel.Log,
+ "",
undefined,
- (wasThrown ? sourceURL : undefined),
- (wasThrown ? lineNumber : undefined),
- (wasThrown ? columnNumber : undefined),
+ sourceURL,
undefined,
- (wasThrown ? undefined : [result]));
- target.consoleModel.addMessage(message);
+ undefined,
+ undefined,
+ [result],
+ undefined);
+ target.consoleModel.addMessage(consoleMessage);
+ },
+
+ /**
+ * @param {!WebInspector.Target} target
+ * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
+ * @param {?string=} sourceURL
+ */
+ _printRunOrCompileScriptResultFailure: function(target, exceptionDetails, sourceURL)
+ {
+ var consoleMessage = new WebInspector.ConsoleMessage(
+ target,
+ exceptionDetails.source,
+ WebInspector.ConsoleMessage.MessageLevel.Error,
+ exceptionDetails.text,
+ undefined,
+ sourceURL,
+ exceptionDetails.line,
+ exceptionDetails.column,
+ undefined,
+ undefined,
+ exceptionDetails.stackTrace);
+ target.consoleModel.addMessage(consoleMessage);
},
/**

Powered by Google App Engine
This is Rietveld 408576698