chore: update warning/error logs

This commit is contained in:
Isaac 2023-06-18 23:57:11 +01:00
parent 5895b3dd6e
commit 6593250945
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33

View File

@ -61,14 +61,15 @@ if (!fs.existsSync('./user/config.yml')) {
const config = YAML.parse(fs.readFileSync('./user/config.yml', 'utf8')); const config = YAML.parse(fs.readFileSync('./user/config.yml', 'utf8'));
const log = logger(config); 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(`Discord Tickets v${pkg.version} on Node.js ${process.version} (${process.platform})`);
log.notice('An error was not caught'); log.warn(origin === 'uncaughtException' ? 'Uncaught exception' : 'Unhandled promise rejection' + ` (${error.name})`);
if (error instanceof Error) log.warn(`Uncaught ${error.name}`);
log.error(error); log.error(error);
}); });
process.on('warning', warning => log.warn(warning.stack));
const client = new Client(config, log); const client = new Client(config, log);
client.login().then(() => { client.login().then(() => {
http(client); http(client);
}); });