diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-09 21:50:03 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-09 21:50:03 -0400 |
commit | 22731b8bf1c66e4d66ee692cd2a650d609c206e0 (patch) | |
tree | e8e9ce0ad467b34abfc5c82ca8129aa51f644700 /src/listeners | |
parent | 20ec27eac550825a596e66220e887fa74a851f6a (diff) | |
download | tanzanite-22731b8bf1c66e4d66ee692cd2a650d609c206e0.tar.gz tanzanite-22731b8bf1c66e4d66ee692cd2a650d609c206e0.tar.bz2 tanzanite-22731b8bf1c66e4d66ee692cd2a650d609c206e0.zip |
warnings
Diffstat (limited to 'src/listeners')
-rw-r--r-- | src/listeners/other/promiseRejection.ts | 7 | ||||
-rw-r--r-- | src/listeners/other/uncaughtException.ts | 7 | ||||
-rw-r--r-- | src/listeners/other/warning.ts | 22 |
3 files changed, 32 insertions, 4 deletions
diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index 130daa3..dc21c3f 100644 --- a/src/listeners/other/promiseRejection.ts +++ b/src/listeners/other/promiseRejection.ts @@ -10,8 +10,11 @@ export default class PromiseRejectionListener extends BushListener { } public override async exec(error: Error): Promise<void> { - // eslint-disable-next-line @typescript-eslint/no-base-to-string - void client.console.error('promiseRejection', `An unhanded promise rejection occurred:\n${error.stack ?? error}`, false); + void client.console.error( + 'promiseRejection', + `An unhanded promise rejection occurred:\n${typeof error == 'object' ? error.stack : error}`, + false + ); if (!error.message.includes('reason: getaddrinfo ENOTFOUND canary.discord.com')) void client.console.channelError({ embeds: [await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error })] diff --git a/src/listeners/other/uncaughtException.ts b/src/listeners/other/uncaughtException.ts index 47db37f..4ba47bd 100644 --- a/src/listeners/other/uncaughtException.ts +++ b/src/listeners/other/uncaughtException.ts @@ -10,8 +10,11 @@ export default class UncaughtExceptionListener extends BushListener { } public override async exec(error: Error): Promise<void> { - // eslint-disable-next-line @typescript-eslint/no-base-to-string - void client.console.error('uncaughtException', `An uncaught exception occurred:\n${error?.stack ?? error}`, false); + void client.console.error( + 'uncaughtException', + `An uncaught exception occurred:\n${typeof error == 'object' ? error.stack : error}`, + false + ); void client.console.channelError({ embeds: [await CommandErrorListener.generateErrorEmbed({ type: 'uncaughtException', error: error })] }); diff --git a/src/listeners/other/warning.ts b/src/listeners/other/warning.ts new file mode 100644 index 0000000..d85e9e3 --- /dev/null +++ b/src/listeners/other/warning.ts @@ -0,0 +1,22 @@ +import { BushListener } from '@lib'; +import CommandErrorListener from '../commands/commandError'; + +export default class WarningListener extends BushListener { + public constructor() { + super('warning', { + emitter: 'process', + event: 'warning' + }); + } + + public override async exec(error: Error): Promise<void> { + void client.console.warn('warning', `A warning occurred:\n${typeof error == 'object' ? error.stack : error}`, false); + void client.console.channelError({ + embeds: [ + (await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error })) + .setColor(util.colors.warn) + .setTitle('A Warning Occurred') + ] + }); + } +} |