Bug 1315242 - Part 2: Display line number and column number in error message for console input. r=bgrins
This commit is contained in:
@@ -147,14 +147,8 @@ module.exports = createClass({
|
|||||||
|
|
||||||
let tooltip = long;
|
let tooltip = long;
|
||||||
|
|
||||||
// If the source is linkable and line > 0
|
// Exclude all falsy values, including `0`, as line numbers start with 1.
|
||||||
const shouldDisplayLine = isLinkable && line;
|
if (line) {
|
||||||
|
|
||||||
// Exclude all falsy values, including `0`, as even
|
|
||||||
// a number 0 for line doesn't make sense, and should not be displayed.
|
|
||||||
// If source isn't linkable, don't attempt to append line and column
|
|
||||||
// info, as this probably doesn't make sense.
|
|
||||||
if (shouldDisplayLine) {
|
|
||||||
tooltip += `:${line}`;
|
tooltip += `:${line}`;
|
||||||
// Intentionally exclude 0
|
// Intentionally exclude 0
|
||||||
if (column) {
|
if (column) {
|
||||||
@@ -193,8 +187,8 @@ module.exports = createClass({
|
|||||||
className: "frame-link-filename",
|
className: "frame-link-filename",
|
||||||
}, displaySource));
|
}, displaySource));
|
||||||
|
|
||||||
// If source is linkable, and we have a line number > 0
|
// If we have a line number > 0.
|
||||||
if (shouldDisplayLine) {
|
if (line) {
|
||||||
let lineInfo = `:${line}`;
|
let lineInfo = `:${line}`;
|
||||||
// Add `data-line` attribute for testing
|
// Add `data-line` attribute for testing
|
||||||
attributes["data-line"] = line;
|
attributes["data-line"] = line;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ function EvaluationResult(props) {
|
|||||||
level,
|
level,
|
||||||
id: messageId,
|
id: messageId,
|
||||||
exceptionDocURL,
|
exceptionDocURL,
|
||||||
|
frame,
|
||||||
} = message;
|
} = message;
|
||||||
|
|
||||||
let messageBody;
|
let messageBody;
|
||||||
@@ -55,6 +56,7 @@ function EvaluationResult(props) {
|
|||||||
scrollToMessage: props.autoscroll,
|
scrollToMessage: props.autoscroll,
|
||||||
serviceContainer,
|
serviceContainer,
|
||||||
exceptionDocURL,
|
exceptionDocURL,
|
||||||
|
frame,
|
||||||
};
|
};
|
||||||
return Message(childProps);
|
return Message(childProps);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,13 +130,12 @@ const Message = createClass({
|
|||||||
const repeat = this.props.repeat ? MessageRepeat({repeat: this.props.repeat}) : null;
|
const repeat = this.props.repeat ? MessageRepeat({repeat: this.props.repeat}) : null;
|
||||||
|
|
||||||
// Configure the location.
|
// Configure the location.
|
||||||
const shouldRenderFrame = frame && frame.source !== "debugger eval code";
|
|
||||||
const location = dom.span({ className: "message-location devtools-monospace" },
|
const location = dom.span({ className: "message-location devtools-monospace" },
|
||||||
shouldRenderFrame ? FrameView({
|
frame ? FrameView({
|
||||||
frame,
|
frame,
|
||||||
onClick: serviceContainer.onViewSourceInDebugger,
|
onClick: serviceContainer ? serviceContainer.onViewSourceInDebugger : undefined,
|
||||||
showEmptyPathAsHost: true,
|
showEmptyPathAsHost: true,
|
||||||
sourceMapService: serviceContainer.sourceMapService
|
sourceMapService: serviceContainer ? serviceContainer.sourceMapService : undefined
|
||||||
}) : null
|
}) : null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ function transformPacket(packet) {
|
|||||||
let {
|
let {
|
||||||
exceptionMessage: messageText,
|
exceptionMessage: messageText,
|
||||||
exceptionDocURL,
|
exceptionDocURL,
|
||||||
|
frame,
|
||||||
result: parameters
|
result: parameters
|
||||||
} = packet;
|
} = packet;
|
||||||
|
|
||||||
@@ -195,6 +196,7 @@ function transformPacket(packet) {
|
|||||||
messageText,
|
messageText,
|
||||||
parameters,
|
parameters,
|
||||||
exceptionDocURL,
|
exceptionDocURL,
|
||||||
|
frame,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -888,7 +888,7 @@ WebConsoleActor.prototype =
|
|||||||
let evalResult = evalInfo.result;
|
let evalResult = evalInfo.result;
|
||||||
let helperResult = evalInfo.helperResult;
|
let helperResult = evalInfo.helperResult;
|
||||||
|
|
||||||
let result, errorDocURL, errorMessage, errorGrip = null;
|
let result, errorDocURL, errorMessage, errorGrip = null, frame = null;
|
||||||
if (evalResult) {
|
if (evalResult) {
|
||||||
if ("return" in evalResult) {
|
if ("return" in evalResult) {
|
||||||
result = evalResult.return;
|
result = evalResult.return;
|
||||||
@@ -929,6 +929,20 @@ WebConsoleActor.prototype =
|
|||||||
try {
|
try {
|
||||||
errorDocURL = ErrorDocs.GetURL(error);
|
errorDocURL = ErrorDocs.GetURL(error);
|
||||||
} catch (ex) {}
|
} catch (ex) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let line = error.errorLineNumber;
|
||||||
|
let column = error.errorColumnNumber;
|
||||||
|
|
||||||
|
if (typeof line === "number" && typeof column === "number") {
|
||||||
|
// Set frame only if we have line/column numbers.
|
||||||
|
frame = {
|
||||||
|
source: "debugger eval code",
|
||||||
|
line,
|
||||||
|
column
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (ex) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,6 +965,7 @@ WebConsoleActor.prototype =
|
|||||||
exception: errorGrip,
|
exception: errorGrip,
|
||||||
exceptionMessage: this._createStringGrip(errorMessage),
|
exceptionMessage: this._createStringGrip(errorMessage),
|
||||||
exceptionDocURL: errorDocURL,
|
exceptionDocURL: errorDocURL,
|
||||||
|
frame,
|
||||||
helperResult: helperResult,
|
helperResult: helperResult,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -1203,6 +1218,8 @@ WebConsoleActor.prototype =
|
|||||||
* in the Inspector (or null, if there is no selection). This is used
|
* in the Inspector (or null, if there is no selection). This is used
|
||||||
* for helper functions that make reference to the currently selected
|
* for helper functions that make reference to the currently selected
|
||||||
* node, like $0.
|
* node, like $0.
|
||||||
|
* - url: the url to evaluate the script as. Defaults to
|
||||||
|
* "debugger eval code".
|
||||||
* @return object
|
* @return object
|
||||||
* An object that holds the following properties:
|
* An object that holds the following properties:
|
||||||
* - dbg: the debugger where the string was evaluated.
|
* - dbg: the debugger where the string was evaluated.
|
||||||
@@ -1212,8 +1229,6 @@ WebConsoleActor.prototype =
|
|||||||
* - result: the result of the evaluation.
|
* - result: the result of the evaluation.
|
||||||
* - helperResult: any result coming from a Web Console commands
|
* - helperResult: any result coming from a Web Console commands
|
||||||
* function.
|
* function.
|
||||||
* - url: the url to evaluate the script as. Defaults to
|
|
||||||
* "debugger eval code".
|
|
||||||
*/
|
*/
|
||||||
evalWithDebugger: function WCA_evalWithDebugger(aString, aOptions = {})
|
evalWithDebugger: function WCA_evalWithDebugger(aString, aOptions = {})
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user