File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -314,6 +314,8 @@ export class ConsoleFormatter {
314314 }
315315
316316 toJSONDetailed ( ) : object {
317+ const location = this . #getTopFrameLocation( ) ;
318+
317319 return {
318320 id : this . #id,
319321 type : this . #type,
@@ -322,6 +324,43 @@ export class ConsoleFormatter {
322324 typeof arg === 'object' ? arg : String ( arg ) ,
323325 ) ,
324326 stackTrace : this . #stack,
327+ ...( location ? { location } : { } ) ,
325328 } ;
326329 }
330+
331+ #getTopFrameLocation( ) :
332+ | { url : string ; lineNumber : number ; columnNumber : number }
333+ | undefined {
334+
335+ if ( ! this . #stack) {
336+ return undefined ;
337+ }
338+
339+ const frame = this . #stack. syncFragment . frames . find (
340+ f => ! this . #isIgnored( f ) ,
341+ ) ;
342+
343+ if ( ! frame ) {
344+ return undefined ;
345+ }
346+
347+ if ( frame . uiSourceCode ) {
348+ const location = frame . uiSourceCode . uiLocation ( frame . line , frame . column ) ;
349+ return {
350+ url : location . uiSourceCode . url ( ) ,
351+ lineNumber : location . lineNumber + 1 ,
352+ columnNumber : location . columnNumber ! + 1 ,
353+ } ;
354+ }
355+
356+ if ( frame . url ) {
357+ return {
358+ url : frame . url ,
359+ lineNumber : frame . line ,
360+ columnNumber : frame . column ,
361+ } ;
362+ }
363+
364+ return undefined ;
365+ }
327366}
You can’t perform that action at this time.
0 commit comments