Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (23 sloc) 871 Bytes

catchError lets you substitute an error on a stream with another stream

const { rxObserver } = require('api/v0.3');
const { timer, throwError, of } = require('rxjs');
const { switchMap, catchError } = require('rxjs/operators');

// emit an error in 5ms
const error$ = timer(5).pipe(
    switchMap(() => throwError('oh'))

const catch$ = error$.pipe(
    catchError(err => of(err))


Check out "Error handling in RxJS" article to get better understanding how not to fail with Observables.

You can’t perform that action at this time.