feat: better command error reporting

This commit is contained in:
TresAbhi committed 2023-05-06 18:03:37 +00:00
1 parent 5ef1f87236
commit 92acbc8e95
16 files changed
+668 -31

No files matched your search

+3 -3
View File
@@ -7,7 +7,7 @@ import isDev from '../utilities/isDev.js';
const PROCESS_ERROR_EVENTS = ['uncaughtException'];
const CLIENT_ERROR_EVENTS = ['error'];
export function handleError(error: Error, client: Client, command?: string) {
export function handleError(error: Error, client: Client, command: string) {
console.error(error);
(
@@ -31,10 +31,10 @@ export function handleError(error: Error, client: Client, command?: string) {
export function registerErrorHandlers() {
if (!isDev()) {
PROCESS_ERROR_EVENTS.forEach((name) =>
process.on(name, (error) => handleError(error, client)),
process.on(name, (error) => handleError(error, client, 'process error')),
);
CLIENT_ERROR_EVENTS.forEach((name) =>
client.on(name, (error) => handleError(error, client)),
client.on(name, (error) => handleError(error, client, 'client error')),
);
}