throwError creates an Observable, that will immediately emit an error
In the example below a value on timer will be substituted with a throwError
stream at 10ms:
123456789101112const { rxObserver } = require('api/v0.3'); const { timer, throwError } = require('rxjs'); const { switchMap } = require('rxjs/operators'); timer(10).pipe( switchMap(()=> throwError('Err!') ) ) .subscribe(rxObserver());
Check out "Error handling in RxJS" article to get better understanding how not to fail with Observables.