From ab950352fab5d80ef8e63cf12278a64f826c5e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Mon, 6 Sep 2021 22:35:49 +0300 Subject: [PATCH] Added uncaughtException event --- src/Client.ts | 4 ++++ src/client/events/uncaughtException.js | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 src/client/events/uncaughtException.js diff --git a/src/Client.ts b/src/Client.ts index 4dc9611..761e7cd 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -85,6 +85,10 @@ class RadioClient extends Client { process.on('SIGTERM', () => { require(`${events}SIGTERM`).execute(this); }); + + process.on('uncaughtException', (error) => { + require(`${events}uncaughtException`).execute(this, error); + }); this.on("error", error => { console.error(error); diff --git a/src/client/events/uncaughtException.js b/src/client/events/uncaughtException.js new file mode 100644 index 0000000..5df8a0b --- /dev/null +++ b/src/client/events/uncaughtException.js @@ -0,0 +1,7 @@ +module.exports = { + name: 'uncaughtException', + execute(client, error) { + console.log(error.stack); + process.emit('SIGINT'); + } +} \ No newline at end of file