@@ -989,28 +989,33 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
989
989
// The Exceptiondetails include script IDs for stack frames, which allows more accurate
990
990
// linking.
991
991
const formatErrorStack =
992
- async ( errorObj : SDK . RemoteObject . RemoteObject , includeCausedByPrefix : boolean ) : Promise < void > => {
992
+ async ( errorObj : SDK . RemoteObject . RemoteObject , includeCausedByPrefix = false ) : Promise < void > => {
993
993
const error = SDK . RemoteObject . RemoteError . objectAsError ( errorObj ) ;
994
994
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 ) ;
997
996
if ( ! errorElement ) {
998
- errorElement = document . createElement ( errorElementType ) ;
997
+ errorElement = document . createElement ( 'span' ) ;
999
998
errorElement . append ( this . linkifyStringAsFragment ( error . errorStack ) ) ;
1000
999
}
1000
+
1001
1001
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 ) ;
1003
1007
}
1004
- result . appendChild ( errorElement ) ;
1005
1008
1006
1009
if ( cause && cause . subtype === 'error' ) {
1007
1010
await formatErrorStack ( cause , /* includeCausedByPrefix */ true ) ;
1008
1011
} 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 ) ;
1010
1015
}
1011
1016
} ;
1012
1017
1013
- this . #formatErrorStackPromiseForTest = formatErrorStack ( output , /* includeCausedByPrefix */ false ) ;
1018
+ this . #formatErrorStackPromiseForTest = formatErrorStack ( output ) ;
1014
1019
1015
1020
return result ;
1016
1021
}
@@ -1752,8 +1757,8 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
1752
1757
}
1753
1758
1754
1759
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 {
1757
1762
const runtimeModel = this . message . runtimeModel ( ) ;
1758
1763
if ( ! runtimeModel ) {
1759
1764
return null ;
@@ -1773,7 +1778,7 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
1773
1778
}
1774
1779
1775
1780
const debuggerModel = runtimeModel . debuggerModel ( ) ;
1776
- const formattedResult = document . createElement ( formattedResultType ) ;
1781
+ const formattedResult = document . createElement ( 'span' ) ;
1777
1782
1778
1783
for ( let i = 0 ; i < linkInfos . length ; ++ i ) {
1779
1784
const newline = i < linkInfos . length - 1 ? '\n' : '' ;
0 commit comments