Skip to content

Commit

Permalink
throw exception if overflowing errorStackLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
zomarg authored and stefanpenner committed Jul 11, 2018
1 parent 8519eac commit 287033f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
// Inspired by http://stackoverflow.com/questions/13227489

module.exports = function getCallerFile(_position) {

const stackTraceLimit = Error.stackTraceLimit-1;
const errorMessage=`ErrorStackTraceLimit overflow. Can pass less then ${stackTraceLimit} or increase property Error.stackTraceLimit`;

if(_position > stackTraceLimit){
throw errorMessage;
}

var oldPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = function(err, stack) { return stack; };
var stack = new Error().stack;
Expand Down

0 comments on commit 287033f

Please sign in to comment.