/** PURE_IMPORTS_START tslib,_innerSubscribe PURE_IMPORTS_END */
|
import * as tslib_1 from "tslib";
|
import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';
|
export function catchError(selector) {
|
return function catchErrorOperatorFunction(source) {
|
var operator = new CatchOperator(selector);
|
var caught = source.lift(operator);
|
return (operator.caught = caught);
|
};
|
}
|
var CatchOperator = /*@__PURE__*/ (function () {
|
function CatchOperator(selector) {
|
this.selector = selector;
|
}
|
CatchOperator.prototype.call = function (subscriber, source) {
|
return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
|
};
|
return CatchOperator;
|
}());
|
var CatchSubscriber = /*@__PURE__*/ (function (_super) {
|
tslib_1.__extends(CatchSubscriber, _super);
|
function CatchSubscriber(destination, selector, caught) {
|
var _this = _super.call(this, destination) || this;
|
_this.selector = selector;
|
_this.caught = caught;
|
return _this;
|
}
|
CatchSubscriber.prototype.error = function (err) {
|
if (!this.isStopped) {
|
var result = void 0;
|
try {
|
result = this.selector(err, this.caught);
|
}
|
catch (err2) {
|
_super.prototype.error.call(this, err2);
|
return;
|
}
|
this._unsubscribeAndRecycle();
|
var innerSubscriber = new SimpleInnerSubscriber(this);
|
this.add(innerSubscriber);
|
var innerSubscription = innerSubscribe(result, innerSubscriber);
|
if (innerSubscription !== innerSubscriber) {
|
this.add(innerSubscription);
|
}
|
}
|
};
|
return CatchSubscriber;
|
}(SimpleOuterSubscriber));
|
//# sourceMappingURL=catchError.js.map
|