2 var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var OuterSubscriber_1 = require("../OuterSubscriber");
17 var InnerSubscriber_1 = require("../InnerSubscriber");
18 var subscribeToResult_1 = require("../util/subscribeToResult");
19 function catchError(selector) {
20 return function catchErrorOperatorFunction(source) {
21 var operator = new CatchOperator(selector);
22 var caught = source.lift(operator);
23 return (operator.caught = caught);
26 exports.catchError = catchError;
27 var CatchOperator = (function () {
28 function CatchOperator(selector) {
29 this.selector = selector;
31 CatchOperator.prototype.call = function (subscriber, source) {
32 return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
36 var CatchSubscriber = (function (_super) {
37 __extends(CatchSubscriber, _super);
38 function CatchSubscriber(destination, selector, caught) {
39 var _this = _super.call(this, destination) || this;
40 _this.selector = selector;
41 _this.caught = caught;
44 CatchSubscriber.prototype.error = function (err) {
45 if (!this.isStopped) {
48 result = this.selector(err, this.caught);
51 _super.prototype.error.call(this, err2);
54 this._unsubscribeAndRecycle();
55 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
56 this.add(innerSubscriber);
57 var innerSubscription = subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
58 if (innerSubscription !== innerSubscriber) {
59 this.add(innerSubscription);
63 return CatchSubscriber;
64 }(OuterSubscriber_1.OuterSubscriber));
65 //# sourceMappingURL=catchError.js.map