catchError (formerly .catch
)
// Throw an error on the 5th emission. Then, create a new observable // and keep going. This also switches letters to numbers. preCatch = timer(0, 1000).pipe( map(i => { if (4 === i) { throw Error; } return i; }), mapNumberToChar(), ); postCatch = new Subject(); caught = this.preCatch.pipe( catchError(() => timer(0, 1000).pipe( take(15), map(value => value + 1), tap(value => this.postCatch.next(value)), finalize(() => this.postCatch.complete()), ), ), );