From 6d7a0e7cfbe02f506710090c5886b1a3840925fa Mon Sep 17 00:00:00 2001 From: Michel Fedde Date: Sun, 22 Jun 2025 14:43:53 +0200 Subject: [PATCH] feat(events): Adds error handling to eventHandlers --- source/Events/EventHandler.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/Events/EventHandler.ts b/source/Events/EventHandler.ts index 48f2ee7..dd41dc5 100644 --- a/source/Events/EventHandler.ts +++ b/source/Events/EventHandler.ts @@ -1,6 +1,8 @@ import cron, {validate} from "node-cron"; import {Class} from "../types/Class"; import {randomUUID} from "node:crypto"; +import {Container} from "../Container/Container"; +import {Logger} from "log4js"; export type EventConfiguration = { name: string, @@ -49,7 +51,11 @@ export class EventHandler { } this.eventHandlers.get(eventName)?.forEach((handler) => { - handler(event); + try { + handler(event); + } catch (e: any) { + Container.get("logger").error(e); + } }) }