Handle unhandled rejections the same way as uncaught exceptions

cshd
Dragory 2020-10-12 20:00:55 +03:00
parent f5caa80c4c
commit c9e0dbf040
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 4 additions and 2 deletions

View File

@ -17,7 +17,7 @@ try {
} }
// Error handling // Error handling
process.on("uncaughtException", err => { function errorHandler(err) {
// Unknown message types (nitro boosting messages at the time) should be safe to ignore // Unknown message types (nitro boosting messages at the time) should be safe to ignore
if (err && err.message && err.message.startsWith("Unhandled MESSAGE_CREATE type")) { if (err && err.message && err.message.startsWith("Unhandled MESSAGE_CREATE type")) {
return; return;
@ -26,7 +26,9 @@ process.on("uncaughtException", err => {
// For everything else, crash with the error // For everything else, crash with the error
console.error(err); console.error(err);
process.exit(1); process.exit(1);
}); }
process.on("uncaughtException", errorHandler);
process.on("unhandledRejection", errorHandler);
let testedPackage = ""; let testedPackage = "";
try { try {