8c2a62f800412efd2c1e94629e7ca0b329301a2c
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm2015 / internal / operators / catchError.js
1 import { OuterSubscriber } from '../OuterSubscriber';
2 import { InnerSubscriber } from '../InnerSubscriber';
3 import { subscribeToResult } from '../util/subscribeToResult';
4 export function catchError(selector) {
5     return function catchErrorOperatorFunction(source) {
6         const operator = new CatchOperator(selector);
7         const caught = source.lift(operator);
8         return (operator.caught = caught);
9     };
10 }
11 class CatchOperator {
12     constructor(selector) {
13         this.selector = selector;
14     }
15     call(subscriber, source) {
16         return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
17     }
18 }
19 class CatchSubscriber extends OuterSubscriber {
20     constructor(destination, selector, caught) {
21         super(destination);
22         this.selector = selector;
23         this.caught = caught;
24     }
25     error(err) {
26         if (!this.isStopped) {
27             let result;
28             try {
29                 result = this.selector(err, this.caught);
30             }
31             catch (err2) {
32                 super.error(err2);
33                 return;
34             }
35             this._unsubscribeAndRecycle();
36             const innerSubscriber = new InnerSubscriber(this, undefined, undefined);
37             this.add(innerSubscriber);
38             const innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
39             if (innerSubscription !== innerSubscriber) {
40                 this.add(innerSubscription);
41             }
42         }
43     }
44 }
45 //# sourceMappingURL=catchError.js.map