Attempt to improve error handling

This commit is contained in:
Chipmunk 2024-11-07 19:44:55 -05:00
parent 62dfc72dbd
commit a24a4590c8

View file

@ -84,11 +84,22 @@ async function main () {
process.on('uncaughtException', error => { process.on('uncaughtException', error => {
if (error.stack.includes('protodef') || error.code === 'Z_BUF_ERROR') { if (error.stack.includes('protodef') || error.code === 'Z_BUF_ERROR') {
console.error('Uncaught protodef exception!\n' + error.stack) console.error('Uncaught packet error!\n' + error.stack)
return // Ignore protodef-related errors (packet-related) return // Ignore packet errors
} }
globalThis.console.error(error) globalThis.console.error(error)
try {
console.end()
} catch {
}
try {
fs.appendSync(console.filename, 'Crashed due to an uncaught exception!\n' + error.stack)
} catch {
}
process.exit(1) process.exit(1)
}) })
} }