I wrote a function that is pipe
-able:
HandleHttpBasicError()
{
return ((source:Observable) => {
return source.pipe(
Is it ok to chain the errors with the throw keyword ?
Yes, it's totally fine. rxjs try-catches such cases and converts it into an error notification.
I tryed to return Observable.throwError() but the browser say "Observable.throwError is not a function"
With rxjs6, the Observable
prototype is no longer modified to contain operators or these »creation operators«, instead they are exposed as standalone functions. You can read more about it here, but the gist of it is that you'd just return throwError(…)
, e.g.
return source$.pipe(
catchError(err => err.code === 404
? throwError("Not found")
: throwError(err)
)
)