Rxjs How To Return Observable With Default Error Handling Function
In my application I have some methods returning an Observable: public myMethodReturningObs(...): Observable { return this.http.get(...); // this will return an Observable } then
Solution 1:
You can catch error in base observable, log it and propogate further
public myMethodReturningObs(...): Observable {
return this.http.get(...)
.catch(e => {
// log error
console.error('Failed', e);
// return same error, so subscriptions also fail
return Rx.Observable.throw(e)
});
}
Post a Comment for "Rxjs How To Return Observable With Default Error Handling Function"