RxJS 6 examples in Angular 6 – Error Handling Operators

Some more RxJS 6 examples in Angular 6. Each example follows the new Angular 6 RxJS 6 coding styles so they are tree-shakable and future-proof.​

 

Error handling – How to catch an error

The “subscribe” method provides an error parameter to catch errors. e.g. myObserverable.subscribe({ error: err => console.error(‘Caught ‘ + err) });.

Try out the example on StackBlitz.

 

catchError – How to gracefully handle errors

The “catchError” operator gracefully handles errors in an observable sequence. e.g. catchError(err => of(err.message)).
Find out why this is important here.

Try out the example on StackBlitz.

 

retry – How to retry an observable sequence when an error occurs

The “retry” operator retries an observable sequence a number of times when an error occur.. e.g. retry(2).

Try out the example on StackBlitz.

 

Other articles in this series

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.