@@ -409,29 +409,17 @@ function evalLC(term) {
409409}
410410
411411// Print an error, with stack trace according to verbosity level
412- function printStackTrace ( error , term , stack ) {
413- if ( config . verbosity == "Calm" ) return ; // No error message for Calm
414- else if ( config . verbosity == "Concise" )
415- console . error ( `${ error } inside definition of <code>${ term . defName } </code>` ) ;
416- else if ( config . verbosity == "Loquacious" ) {
417- // Loquacious will provide a stack trace localised to the definition
418- if ( stack . length == 0 || stack [ stack . length - 1 ] == term . defName )
419- console . error ( `${ error } inside definition of <code>${ term . defName } </code>` ) ;
420- else {
421- const localStack = stack . slice ( stack . indexOf ( term . defName ) + 1 ) . reverse ( ) ;
422- console . error ( `${ error } inside definition of <code>${ term . defName } </code>
423- ${ localStack . map ( v => '\twhile evaluating <code>' + v + '</code>' ) . join ( '\n' ) } `)
424- }
425- } else if ( config . verbosity == "Verbose" ) {
426- // Verbose will provide a full stack trace
427- if ( stack . length == 0 )
428- console . error ( `${ error } inside definition of <code>${ term . defName } </code>` ) ;
429- else {
430- const localStack = stack . reverse ( ) ;
431- console . error ( `${ error } inside definition of <code>${ term . defName } </code>
432- ${ localStack . map ( v => '\twhile evaluating <code>' + v + '</code>' ) . join ( '\n' ) } `)
433- }
434- }
412+ function printStackTrace ( error , term , stack ) { console . log ( "printStackTrace" , config . verbosity )
413+ if ( config . verbosity >= "Concise" )
414+ console . error ( `${ error } inside definition of <code>${ term . defName } </code>` ) ;
415+
416+ const stackCutoff = config . verbosity < "Verbose" && stack [ stack . length - 1 ] == term . defName ? stack . indexOf ( term . defName ) + 1 : 0 ;
417+
418+ if ( config . verbosity >= "Loquacious" )
419+ console . error ( stack . slice ( stackCutoff ) . reverse ( ) . map ( v => `\twhile evaluating <code>${ v } </code>` ) . join ( '\n' ) ) ;
420+
421+ if ( config . verbosity >= "Verbose" )
422+ console . error ( stack . slice ( ) . reverse ( ) . map ( v => `\twhile evaluating <code>${ v } </code>` ) . join ( '\n' ) ) ;
435423}
436424
437425Object . defineProperty ( Function . prototype , "valueOf" , { value : function valueOf ( ) { return toInt ( this ) ; } } ) ;
0 commit comments