aboutsummaryrefslogtreecommitdiff
path: root/src/listeners
diff options
context:
space:
mode:
Diffstat (limited to 'src/listeners')
-rw-r--r--src/listeners/other/promiseRejection.ts7
-rw-r--r--src/listeners/other/uncaughtException.ts7
-rw-r--r--src/listeners/other/warning.ts22
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')
+ ]
+ });
+ }
+}