I am trying to catch the errors in rxjs using the catchError operator und want to retry 3 time only if I get an errno=215
return this.httpService.post(url, data).pipe(
tap(() => {
console.log(`some debugging info`);
}),
map((response) => responseAdaptor(response)),
retryWhen((error) => {
return error.pipe(
scan((acc, error) => {
// RETRY ONLY IF ERROR error.errno == 215
if (acc > 2) throw error;
return acc + 1;
}, 0),
delay(1000)
);
}),
catchError((error) => {
console.log(error);
// Here I want the use `throwError`
return of({ error: error.response });
})
);
Here is what I tried but unfortunately no idea how to combine scan counter and errno.