From 0f36df9f07899cedfe2fbb8688a2d8efe1cb38b8 Mon Sep 17 00:00:00 2001 From: prakharlowanshi Date: Sat, 20 Jun 2026 14:18:53 +0530 Subject: [PATCH] use the retry logic --- ...services-interceptor-error-interceptor.module.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/services/interceptor/error-interceptor/src/lib/services-interceptor-error-interceptor.module.ts b/libs/services/interceptor/error-interceptor/src/lib/services-interceptor-error-interceptor.module.ts index dde7a26b..32429ae1 100644 --- a/libs/services/interceptor/error-interceptor/src/lib/services-interceptor-error-interceptor.module.ts +++ b/libs/services/interceptor/error-interceptor/src/lib/services-interceptor-error-interceptor.module.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; -import { EMPTY, Observable, throwError } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { EMPTY, Observable, of, throwError } from 'rxjs'; +import { catchError, retry } from 'rxjs/operators'; import { Router } from '@angular/router'; import { PrimeNgToastService } from '@proxy/ui/prime-ng-toast'; import { AngularFireAuth } from '@angular/fire/compat/auth'; @@ -27,6 +27,15 @@ export class ErrorInterceptor implements HttpInterceptor { this.cookieService.get('authToken') ) { return next.handle(request).pipe( + retry({ + count: 1, + delay: (error: HttpErrorResponse) => { + if (error instanceof HttpErrorResponse && error.status === 0) { + return of(null); + } + return throwError(() => error); + }, + }), catchError((err) => { if (err instanceof HttpErrorResponse) { if (err.status === 401) {