Attempt to improve error handling
This commit is contained in:
parent
62dfc72dbd
commit
a24a4590c8
1 changed files with 13 additions and 2 deletions
15
index.js
15
index.js
|
@ -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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue