From b24992ad2429323412da35db5daba5045d2435f7 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Thu, 15 Jan 2026 13:11:18 +0100 Subject: [PATCH] frontend: Improves HTTP error handling Refactors error handling to allow handlers to directly return a response. Updates the error handler service to return null when no handler can process an error. --- .../src/lib/shared/interceptors/http.interceptor.ts | 8 ++++---- .../lib/shared/services/http-error-notifier.service.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/interceptors/http.interceptor.ts b/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/interceptors/http.interceptor.ts index 2ac45294..ffb8abca 100644 --- a/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/interceptors/http.interceptor.ts +++ b/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/interceptors/http.interceptor.ts @@ -52,17 +52,17 @@ export const httpInterceptor: HttpInterceptorFn = (req: HttpRequest, ne return next(req).pipe( catchError((error: HttpErrorResponse) => { // Attempt recovery through registered domain handlers - const recovery$ = httpErrorNotifier.handle({ + const responseHandler$ = httpErrorNotifier.handle({ error, request: req, pageUrl, next }); - // If a handler provided a recovery strategy, use it + // If a handler provided a response Observable, return it // Otherwise, rethrow the error - if (recovery$) { - return recovery$; + if (responseHandler$) { + return responseHandler$; } return throwError(() => error); diff --git a/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/http-error-notifier.service.ts b/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/http-error-notifier.service.ts index 68120c0e..4d16bf4c 100644 --- a/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/http-error-notifier.service.ts +++ b/meet-ce/frontend/projects/shared-meet-components/src/lib/shared/services/http-error-notifier.service.ts @@ -1,6 +1,6 @@ import { HttpErrorResponse, HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { EMPTY, Observable } from 'rxjs'; +import { Observable } from 'rxjs'; /** * Context information about an HTTP error @@ -51,12 +51,12 @@ export class HttpErrorNotifierService { /** * Attempts to recover from an HTTP error by consulting registered handlers. - * Returns an Observable from the first handler that can recover, or EMPTY if none can handle it. + * Returns an Observable from the first handler that can recover, or null if none can handle it. * * @param context The error context - * @returns Observable to retry the request, or EMPTY if no handler can recover + * @returns Observable to retry the request, or null if no handler can recover */ - public handle(context: HttpErrorContext): Observable> { + public handle(context: HttpErrorContext): Observable> | null { for (const handler of this.handlers) { if (handler.canHandle(context)) { return handler.handle(context); @@ -64,6 +64,6 @@ export class HttpErrorNotifierService { } // No handler could handle this error - return EMPTY; + return null; } }