Skip to content

Commit

Permalink
Merge pull request #10 from phetsims/stack-trace-limit/assert/9
Browse files Browse the repository at this point in the history
Increase stack trace limit for Errors created by assert
  • Loading branch information
zepumph authored May 14, 2024
2 parents 9c7053e + 27cf5d5 commit a5da36d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
if ( window.QueryStringMachine && QueryStringMachine.containsKey( 'debugger' ) ) {
debugger; // eslint-disable-line no-debugger
}

// Check if Error.stackTraceLimit exists and is writable
const descriptor = Object.getOwnPropertyDescriptor( Error, 'stackTraceLimit' );
const stackTraceWritable = descriptor && ( descriptor.writable || ( descriptor.set && typeof descriptor.set === 'function' ) );

if ( stackTraceWritable ) {

// @ts-ignore
Error.stackTraceLimit = 20;
}

throw new Error( assertPrefix + messages.join( '\n ' ) );
}
};
Expand Down

0 comments on commit a5da36d

Please sign in to comment.