From 6593250945ca8fb9d3e84dcb33eee5d82a64a8e8 Mon Sep 17 00:00:00 2001 From: Isaac Date: Sun, 18 Jun 2023 23:57:11 +0100 Subject: [PATCH] chore: update warning/error logs --- src/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 65f5ba5..62126c6 100644 --- a/src/index.js +++ b/src/index.js @@ -61,14 +61,15 @@ if (!fs.existsSync('./user/config.yml')) { const config = YAML.parse(fs.readFileSync('./user/config.yml', 'utf8')); const log = logger(config); -process.on('unhandledRejection', error => { +process.on('uncaughtException', (error, origin) => { log.notice(`Discord Tickets v${pkg.version} on Node.js ${process.version} (${process.platform})`); - log.notice('An error was not caught'); - if (error instanceof Error) log.warn(`Uncaught ${error.name}`); + log.warn(origin === 'uncaughtException' ? 'Uncaught exception' : 'Unhandled promise rejection' + ` (${error.name})`); log.error(error); }); +process.on('warning', warning => log.warn(warning.stack)); + const client = new Client(config, log); client.login().then(() => { http(client); -}); \ No newline at end of file +});