From 94c20f17f1a87e594fc07a75eb6026891086c67c Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 27 May 2022 22:39:07 -0400 Subject: fix: use util#formatError --- src/listeners/commands/commandError.ts | 4 ++-- src/listeners/contextCommands/contextCommandError.ts | 2 +- src/listeners/other/promiseRejection.ts | 6 +----- src/listeners/other/uncaughtException.ts | 6 +----- src/listeners/other/warning.ts | 2 +- 5 files changed, 6 insertions(+), 14 deletions(-) (limited to 'src/listeners') diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index d590e06..895cff0 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -46,7 +46,7 @@ export default class CommandErrorListener extends BushListener { `${isSlash ? 'slashC' : 'c'}ommandError`, `an error occurred with the <<${command}>> ${isSlash ? 'slash ' : ''}command in <<${channel}>> triggered by <<${ message?.author?.tag - }>>:\n${error?.stack ?? error}`, + }>>:\n${util.formatError(error)})}`, false ); @@ -229,7 +229,7 @@ export default class CommandErrorListener extends BushListener { } public static async getErrorStack(error: Error | any): Promise { - return await util.inspectCleanRedactCodeblock(error?.stack ?? error, 'js'); + return await util.inspectCleanRedactCodeblock(util.formatError(error), 'js'); } } diff --git a/src/listeners/contextCommands/contextCommandError.ts b/src/listeners/contextCommands/contextCommandError.ts index 04a97ad..86cbac8 100644 --- a/src/listeners/contextCommands/contextCommandError.ts +++ b/src/listeners/contextCommands/contextCommandError.ts @@ -44,7 +44,7 @@ export default class ContextCommandErrorListener extends BushListener { `contextCommandError`, `an error occurred with the <<${command}>> context command in <<${channel}>> triggered by <<${ interaction?.user?.tag - }>>:\n${error?.stack ?? error}`, + }>>:\n${util.formatError(error)}`, false ); diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index 69a62c7..270db46 100644 --- a/src/listeners/other/promiseRejection.ts +++ b/src/listeners/other/promiseRejection.ts @@ -21,11 +21,7 @@ export default class PromiseRejectionListener extends BushListener { level: Severity.Error }); - void client.console.error( - 'promiseRejection', - `An unhanded promise rejection occurred:\n${typeof error == 'object' ? error.stack : error}`, - false - ); + void client.console.error('promiseRejection', `An unhanded promise rejection occurred:\n${util.formatError(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 b650620..b12f76d 100644 --- a/src/listeners/other/uncaughtException.ts +++ b/src/listeners/other/uncaughtException.ts @@ -20,11 +20,7 @@ export default class UncaughtExceptionListener extends BushListener { level: Severity.Error }); - void client.console.error( - 'uncaughtException', - `An uncaught exception occurred:\n${typeof error == 'object' ? error.stack : error}`, - false - ); + void client.console.error('uncaughtException', `An uncaught exception occurred:\n${util.formatError(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 index 57f2a7d..2412221 100644 --- a/src/listeners/other/warning.ts +++ b/src/listeners/other/warning.ts @@ -17,7 +17,7 @@ export default class WarningListener extends BushListener { level: Severity.Warning }); - void client.console.warn('warning', `A warning occurred:\n${typeof error == 'object' ? error.stack : error}`, false); + void client.console.warn('warning', `A warning occurred:\n${util.formatError(error)}`, false); void client.console.channelError({ embeds: [ (await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error })) -- cgit