I want to catch the exception in subscribe but the result is not being as expected.
this.userService.isUsernameValid (username)
.pipe (
catchError (err =>
{
return throwError (err);
}),
retryWhen (errors =>
errors.pipe (
delay (2500),
take (4),
concatMap (() => throwError ('Network error'))
)
)
)
.subscribe (
data =>
{
//
},
error =>
{
console.log (error)
});
I would like the exception to be thrown only if all attempts fail.
The code above only makes the first request and in case of an error throws the exception (does not redo the request).
If I remove the concatMap the 4 attempts will be made but I will not be able to catch the error within the subscribe if none is successful.
Thanks in advance.