diff --git a/src/listeners/errors/listenerError.ts b/src/listeners/errors/listenerError.ts index be327bc6bae..f32dd9d8a03 100644 --- a/src/listeners/errors/listenerError.ts +++ b/src/listeners/errors/listenerError.ts @@ -1,7 +1,10 @@ -import { Events, Listener, type ListenerErrorPayload } from '@sapphire/framework'; +import { Events, Listener, UserError, type ListenerErrorPayload } from '@sapphire/framework'; export class UserListener extends Listener { public run(error: Error, context: ListenerErrorPayload) { + // We generally do not care about `UserError`s in listeners since they're not bugs. + if (error instanceof UserError) return; + this.container.logger.fatal(`[EVENT] ${context.piece.name}\n${error.stack || error.message}`); } } diff --git a/src/listeners/errors/listenerErrorSentry.ts b/src/listeners/errors/listenerErrorSentry.ts index 9bd9ddf075d..42a8d50eb63 100644 --- a/src/listeners/errors/listenerErrorSentry.ts +++ b/src/listeners/errors/listenerErrorSentry.ts @@ -1,11 +1,14 @@ import { ApplyOptions } from '@sapphire/decorators'; -import { Events, Listener, type ListenerErrorPayload } from '@sapphire/framework'; +import { Events, Listener, UserError, type ListenerErrorPayload } from '@sapphire/framework'; import { captureException } from '@sentry/node'; import { envIsDefined } from '@skyra/env-utilities'; @ApplyOptions({ enabled: envIsDefined('SENTRY_URL') }) export class UserListener extends Listener { public run(error: Error, context: ListenerErrorPayload) { + // We generally do not care about `UserError`s in listeners since they're not bugs. + if (error instanceof UserError) return; + captureException(error, { tags: { name: context.piece.name } }); } }