Is it possible for a base class to catch
certain errors before allowing the subclass to subscribe
to the observable in Angular2.
e.g.
Using catch
alone does not help much since you have client code subscribed and you must return Observable
from catch
.
I would implement it as follows:
Rx.Observable.of(42)
.do(v=>{throw new Error('test')})
.catch(Rx.Observable.of(undefined))
.filter(v=>{return v !== undefined})
.subscribe(
(e)=>{console.log('next', e)},
(e)=>{console.log('error', e)},
()=>{console.log('complete')}
);