1 | /** PURE_IMPORTS_START tslib,_innerSubscribe PURE_IMPORTS_END */
|
---|
2 | import * as tslib_1 from "tslib";
|
---|
3 | import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';
|
---|
4 | export function catchError(selector) {
|
---|
5 | return function catchErrorOperatorFunction(source) {
|
---|
6 | var operator = new CatchOperator(selector);
|
---|
7 | var caught = source.lift(operator);
|
---|
8 | return (operator.caught = caught);
|
---|
9 | };
|
---|
10 | }
|
---|
11 | var CatchOperator = /*@__PURE__*/ (function () {
|
---|
12 | function CatchOperator(selector) {
|
---|
13 | this.selector = selector;
|
---|
14 | }
|
---|
15 | CatchOperator.prototype.call = function (subscriber, source) {
|
---|
16 | return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
|
---|
17 | };
|
---|
18 | return CatchOperator;
|
---|
19 | }());
|
---|
20 | var CatchSubscriber = /*@__PURE__*/ (function (_super) {
|
---|
21 | tslib_1.__extends(CatchSubscriber, _super);
|
---|
22 | function CatchSubscriber(destination, selector, caught) {
|
---|
23 | var _this = _super.call(this, destination) || this;
|
---|
24 | _this.selector = selector;
|
---|
25 | _this.caught = caught;
|
---|
26 | return _this;
|
---|
27 | }
|
---|
28 | CatchSubscriber.prototype.error = function (err) {
|
---|
29 | if (!this.isStopped) {
|
---|
30 | var result = void 0;
|
---|
31 | try {
|
---|
32 | result = this.selector(err, this.caught);
|
---|
33 | }
|
---|
34 | catch (err2) {
|
---|
35 | _super.prototype.error.call(this, err2);
|
---|
36 | return;
|
---|
37 | }
|
---|
38 | this._unsubscribeAndRecycle();
|
---|
39 | var innerSubscriber = new SimpleInnerSubscriber(this);
|
---|
40 | this.add(innerSubscriber);
|
---|
41 | var innerSubscription = innerSubscribe(result, innerSubscriber);
|
---|
42 | if (innerSubscription !== innerSubscriber) {
|
---|
43 | this.add(innerSubscription);
|
---|
44 | }
|
---|
45 | }
|
---|
46 | };
|
---|
47 | return CatchSubscriber;
|
---|
48 | }(SimpleOuterSubscriber));
|
---|
49 | //# sourceMappingURL=catchError.js.map
|
---|