Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (event.detail && event.detail.reason) {
error = event.detail.reason
isBluebird = true
}
} catch (e) {}
const handledState = {
severity: 'error',
unhandled: true,
severityReason: { type: 'unhandledPromiseRejection' }
}
let report
if (error && hasStack(error)) {
// if it quacks like an Error…
report = new client.BugsnagReport(error.name, error.message, ErrorStackParser.parse(error), handledState, error)
if (isBluebird) {
report.stacktrace = reduce(report.stacktrace, fixBluebirdStacktrace(error), [])
}
} else {
// if it doesn't…
const msg = 'Rejection reason was not an Error. See "Promise" tab for more detail.'
report = new client.BugsnagReport(
error && error.name ? error.name : 'UnhandledRejection',
error && error.message ? error.message : msg,
[],
handledState,
error
)
// stuff the rejection reason into metaData, it could be useful
report.updateMetaData('promise', 'rejection reason', serializableReason(error))
}