Skip to content

Commit

Permalink
fix: olympic-countries service add max retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwaadpepper committed Oct 4, 2024
1 parent fcaaa95 commit 103f9a3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/core/services/olympic-countries.service.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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))
}),
)
}
Expand Down

0 comments on commit 103f9a3

Please sign in to comment.