From 103f9a338ac7fc3bfdfd6d2c4e2d8ed539e505a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Fri, 4 Oct 2024 14:08:16 +0200 Subject: [PATCH] fix: olympic-countries service add max retry --- src/app/core/services/olympic-countries.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/core/services/olympic-countries.service.ts b/src/app/core/services/olympic-countries.service.ts index a49a0942b..1a619bb02 100644 --- a/src/app/core/services/olympic-countries.service.ts +++ b/src/app/core/services/olympic-countries.service.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http' import { Injectable, OnDestroy } from '@angular/core' import { cloneDeep } from 'lodash-es' -import { BehaviorSubject, catchError, Observable, Subject, take, tap } from 'rxjs' +import { BehaviorSubject, catchError, Observable, retry, Subject, take, tap, throwError } from 'rxjs' import OlympicCountry from '../models/olympic-country.interface' import { ToastService } from './toast.service' @@ -41,12 +41,14 @@ export class OlympicService implements OnDestroy { this.olympicCountries = value this.olympicCountries$.next(cloneDeep(value)) }), - catchError((error, caught) => { + + retry(3), + catchError(() => { const message = $localize`Error while fetching olympic countries from server` this.toastService.error(message) this.olympicCountries$.next([]) this.olympicCountries$.error(message) - return caught + return throwError(() => new Error(message)) }), ) }