chore(pockethost): enhance unhandled exception debugging information

This commit is contained in:
Ben Allfree 2024-07-30 09:41:22 -04:00
parent 114ce3739a
commit 77e91315fd

View File

@ -1,23 +1,23 @@
import { ioc } from '.'
import { DEBUG } from '.'
import { discordAlert } from './discordAlert'
import { gracefulExit } from './exit'
;['unhandledRejection', 'uncaughtException'].forEach((type) => {
process.on(type, (e) => {
console.error(e)
console.error(`Unhandled:`, e)
try {
discordAlert(e)
} catch (e) {
console.error(e)
console.error(`Failed to alert Discord:`, e)
}
const debug = (() => {
try {
return ioc.service('settings').DEBUG
return DEBUG()
} catch {
return true
}
})()
if (debug) {
console.error(e.stack)
console.error(`Unhandled debug trace:`, e.stack)
gracefulExit()
}
})