mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
chore(pockethost): enhance unhandled exception debugging information
This commit is contained in:
parent
114ce3739a
commit
77e91315fd
@ -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()
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user