I am trying to make an error inside rxjs Observable
new Observable(subscriber => { Observable.throw("error1"); return Observable.throw("error2"); }) .subscribe( () => {}, err => console.error(err) );
Error 1 is not caught.
error2 gives a compilation error:
Argument of type '(this: Observable<{}>, subscriber: Subscriber<{}>) => ErrorObservable<string>' is not assignable to parameter of type '(this: Observable<{}>, subscriber: Subscriber<{}>) => TeardownLogic'. Type 'ErrorObservable<string>' is not assignable to type 'TeardownLogic'
What is the correct way to throw an error inside the observable?
javascript reactive-programming error-handling rxjs
phzonta
source share