UNPKG

wed

Version:

Wed is a schema-aware editor for XML documents.

62 lines (58 loc) 2.17 kB
define(function(require,exports,module){ /** PURE_IMPORTS_START tslib,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */ import * as tslib_1 from "tslib"; import { OuterSubscriber } from '../OuterSubscriber'; import { subscribeToResult } from '../util/subscribeToResult'; 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; }()); /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ 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; } // NOTE: overriding `error` instead of `_error` because we don't want // to have this flag this subscriber as `isStopped`. We can mimic the // behavior of the RetrySubscriber (from the `retry` operator), where // we unsubscribe from our source chain, reset our Subscriber flags, // then subscribe to the selector result. 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(); this.add(subscribeToResult(this, result)); } }; return CatchSubscriber; }(OuterSubscriber)); //# sourceMappingURL=catchError.js.map return module.exports; });