[#121] added error handler and snackbar

This commit is contained in:
Camille Moussu
2025-10-08 18:14:15 +02:00
committed by Benoit TELLIER
parent f498309f44
commit a00f179dbd
6 changed files with 187 additions and 51 deletions
+25
View File
@@ -0,0 +1,25 @@
export class EventErrorHandler {
private errors = new Map<string, string>();
private onErrorCallback?: (messages: string[]) => void;
setErrorCallback(callback: (messages: string[]) => void) {
this.onErrorCallback = callback;
}
reportError(eventId: string, message: string) {
if (!this.errors.has(eventId)) {
this.errors.set(eventId, message);
console.warn(`[EventErrorHandler] ${eventId}: ${message}`);
this.emit();
}
}
clearAll() {
this.errors.clear();
this.emit();
}
private emit() {
this.onErrorCallback?.(Array.from(this.errors.values()));
}
}