Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
BugsnagReport.getStacktrace = function (error, errorFramesToSkip = 0, generatedFramesToSkip = 0) {
if (hasStack(error)) return ErrorStackParser.parse(error).slice(errorFramesToSkip)
// in IE11 a new Error() doesn't have a stacktrace until you throw it, so try that here
try {
throw error
} catch (e) {
if (hasStack(e)) return ErrorStackParser.parse(error).slice(1 + generatedFramesToSkip)
// error wasn't provided or didn't have a stacktrace so try to walk the callstack
try {
return filter(StackGenerator.backtrace(), frame =>
(frame.functionName || '').indexOf('StackGenerator$$') === -1
).slice(1 + generatedFramesToSkip)
} catch (e) {
return []
}
}
}
BugsnagReport.getStacktrace = (error, errorFramesToSkip = 0, generatedFramesToSkip = 0) => {
if (hasStack(error)) return ErrorStackParser.parse(error).slice(errorFramesToSkip)
// error wasn't provided or didn't have a stacktrace so try to walk the callstack
return filter(StackGenerator.backtrace(), frame =>
(frame.functionName || '').indexOf('StackGenerator$$') === -1
).slice(1 + generatedFramesToSkip)
}
generateArtificially: function StackTrace$$generateArtificially (opts) {
opts = utils.mergeObject(defaultOptions, opts)
var stackFrames = StackGenerator.backtrace(opts)
if (typeof opts.filter === 'function') {
stackFrames = stackFrames.filter(opts.filter)
}
return ErrorStackNormalizer(stackFrames)
},
generateArtificially: function StackTrace$$generateArtificially(opts) {
opts = utils.mergeObject(defaultOptions, opts)
var stackFrames = StackGenerator.backtrace(opts);
if (typeof opts.filter === 'function') {
stackFrames = stackFrames.filter(opts.filter);
}
return Promise.resolve(stackFrames);
},