-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add optional default error events (#141)
- Loading branch information
1 parent
297581d
commit 27fd086
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { PieceContext } from '@sapphire/pieces'; | ||
import { Event } from '../lib/structures/Event'; | ||
import { CommandErrorPayload, Events } from '../lib/types/Events'; | ||
|
||
export class CoreEvent extends Event<Events.CommandError> { | ||
public constructor(context: PieceContext) { | ||
super(context, { event: Events.CommandError }); | ||
} | ||
|
||
public run(error: Error, context: CommandErrorPayload) { | ||
const { name, path } = context.piece; | ||
this.context.logger.error(`Encountered error on command "${name}" at path "${path}"`, error.stack); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { PieceContext } from '@sapphire/pieces'; | ||
import { Event } from '../lib/structures/Event'; | ||
import { EventErrorPayload, Events } from '../lib/types/Events'; | ||
|
||
export class CoreEvent extends Event<Events.EventError> { | ||
public constructor(context: PieceContext) { | ||
super(context, { event: Events.EventError }); | ||
} | ||
|
||
public run(error: Error, context: EventErrorPayload) { | ||
const { name, event, path } = context.piece; | ||
this.context.logger.error(`Encountered error on event listener "${name}" for event "${event}" at path "${path}"`, error.stack); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters