There is more to a stream than just generating data; a stream can generate errors as well as reaching its completion. If an error or a completion happens, the stream will not generate any more values. To signal that we have an error, we call the error() method on the Observer, like so:
let stream$ = Rx.Observable.create(observer => { observer.error('we have an error');});
To capture the emitted error, we need to introduce a second callback in our call to subscribe(), like so:
// rxjs-example/error.js const Rx = require("rxjs/Rx");let stream$ = Rx.Observable.create(observer => { observer.error("we have an error");});stream$.subscribe( data => console.log("data", data), error => console.error("err", error))