Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

catchError.js 1.8KB

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