Skip to content

Commit 761b969

Browse files
authored
fixed missing new line before string error causes (#186)
1 parent 7774c38 commit 761b969

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

front_end/panels/console/ConsoleViewMessage.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -989,28 +989,33 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
989989
// The Exceptiondetails include script IDs for stack frames, which allows more accurate
990990
// linking.
991991
const formatErrorStack =
992-
async(errorObj: SDK.RemoteObject.RemoteObject, includeCausedByPrefix: boolean): Promise<void> => {
992+
async(errorObj: SDK.RemoteObject.RemoteObject, includeCausedByPrefix = false): Promise<void> => {
993993
const error = SDK.RemoteObject.RemoteError.objectAsError(errorObj);
994994
const [details, cause] = await Promise.all([error.exceptionDetails(), error.cause()]);
995-
const errorElementType = includeCausedByPrefix ? 'div' : 'span';
996-
let errorElement = this.tryFormatAsError(error.errorStack, details, errorElementType);
995+
let errorElement = this.tryFormatAsError(error.errorStack, details);
997996
if (!errorElement) {
998-
errorElement = document.createElement(errorElementType);
997+
errorElement = document.createElement('span');
999998
errorElement.append(this.linkifyStringAsFragment(error.errorStack));
1000999
}
1000+
10011001
if (includeCausedByPrefix) {
1002-
errorElement.prepend('Caused by: ');
1002+
const causeElement = document.createElement('div');
1003+
causeElement.append('Caused by: ', errorElement);
1004+
result.appendChild(causeElement);
1005+
} else {
1006+
result.appendChild(errorElement);
10031007
}
1004-
result.appendChild(errorElement);
10051008

10061009
if (cause && cause.subtype === 'error') {
10071010
await formatErrorStack(cause, /* includeCausedByPrefix */ true);
10081011
} else if (cause && cause.type === 'string') {
1009-
result.append(`Caused by: ${cause.value}`);
1012+
const stringCauseElement = document.createElement('div');
1013+
stringCauseElement.append(`Caused by: ${cause.value}`);
1014+
result.append(stringCauseElement);
10101015
}
10111016
};
10121017

1013-
this.#formatErrorStackPromiseForTest = formatErrorStack(output, /* includeCausedByPrefix */ false);
1018+
this.#formatErrorStackPromiseForTest = formatErrorStack(output);
10141019

10151020
return result;
10161021
}
@@ -1752,8 +1757,8 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
17521757
}
17531758

17541759
private tryFormatAsError(
1755-
string: string, exceptionDetails?: Protocol.Runtime.ExceptionDetails,
1756-
formattedResultType: 'div'|'span' = 'span'): HTMLElement|null {
1760+
string: string, exceptionDetails?: Protocol.Runtime.ExceptionDetails
1761+
): HTMLElement|null {
17571762
const runtimeModel = this.message.runtimeModel();
17581763
if (!runtimeModel) {
17591764
return null;
@@ -1773,7 +1778,7 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
17731778
}
17741779

17751780
const debuggerModel = runtimeModel.debuggerModel();
1776-
const formattedResult = document.createElement(formattedResultType);
1781+
const formattedResult = document.createElement('span');
17771782

17781783
for (let i = 0; i < linkInfos.length; ++i) {
17791784
const newline = i < linkInfos.length - 1 ? '\n' : '';

0 commit comments

Comments
 (0)