1
0
mirror of synced 2025-12-22 03:16:52 -05:00
Files
docs/lib/handle-exceptions.js
Peter Bengtsson fab5bef972 Avoid an infinite FailBot.report() loop (#22837)
* Avoid an infinite FailBot.report() loop

Part of #1221

* Update middleware/events.js

Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>

Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
2021-11-16 01:05:03 +00:00

29 lines
793 B
JavaScript

import FailBot from './failbot.js'
process.on('uncaughtException', async (err) => {
if (err.code === 'MODULE_NOT_FOUND') {
console.error('\n\n🔥 Uh oh! It looks you are missing a required npm module.')
console.error(
'Please run `npm install` to make sure you have all the required dependencies.\n\n'
)
}
console.error(err)
try {
await FailBot.report(err)
} catch (failBotError) {
console.warn('Even sending the uncaughtException error to FailBot failed!')
console.error(failBotError)
}
})
process.on('unhandledRejection', async (err) => {
console.error(err)
try {
await FailBot.report(err)
} catch (failBotError) {
console.warn('Even sending the unhandledRejection error to FailBot failed!')
console.error(failBotError)
}
})