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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { OuterSubscriber } from '../OuterSubscriber';
  2. import { InnerSubscriber } from '../InnerSubscriber';
  3. import { subscribeToResult } from '../util/subscribeToResult';
  4. export function catchError(selector) {
  5. return function catchErrorOperatorFunction(source) {
  6. const operator = new CatchOperator(selector);
  7. const caught = source.lift(operator);
  8. return (operator.caught = caught);
  9. };
  10. }
  11. class CatchOperator {
  12. constructor(selector) {
  13. this.selector = selector;
  14. }
  15. call(subscriber, source) {
  16. return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
  17. }
  18. }
  19. class CatchSubscriber extends OuterSubscriber {
  20. constructor(destination, selector, caught) {
  21. super(destination);
  22. this.selector = selector;
  23. this.caught = caught;
  24. }
  25. error(err) {
  26. if (!this.isStopped) {
  27. let result;
  28. try {
  29. result = this.selector(err, this.caught);
  30. }
  31. catch (err2) {
  32. super.error(err2);
  33. return;
  34. }
  35. this._unsubscribeAndRecycle();
  36. const innerSubscriber = new InnerSubscriber(this, undefined, undefined);
  37. this.add(innerSubscriber);
  38. subscribeToResult(this, result, undefined, undefined, innerSubscriber);
  39. }
  40. }
  41. }
  42. //# sourceMappingURL=catchError.js.map