a zip code crypto-currency system good for red ONLY

catch.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /** PURE_IMPORTS_START .._operators_catchError PURE_IMPORTS_END */
  2. import { catchError as higherOrder } from '../operators/catchError';
  3. /**
  4. * Catches errors on the observable to be handled by returning a new observable or throwing an error.
  5. *
  6. * <img src="./img/catch.png" width="100%">
  7. *
  8. * @example <caption>Continues with a different Observable when there's an error</caption>
  9. *
  10. * Observable.of(1, 2, 3, 4, 5)
  11. * .map(n => {
  12. * if (n == 4) {
  13. * throw 'four!';
  14. * }
  15. * return n;
  16. * })
  17. * .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
  18. * .subscribe(x => console.log(x));
  19. * // 1, 2, 3, I, II, III, IV, V
  20. *
  21. * @example <caption>Retries the caught source Observable again in case of error, similar to retry() operator</caption>
  22. *
  23. * Observable.of(1, 2, 3, 4, 5)
  24. * .map(n => {
  25. * if (n === 4) {
  26. * throw 'four!';
  27. * }
  28. * return n;
  29. * })
  30. * .catch((err, caught) => caught)
  31. * .take(30)
  32. * .subscribe(x => console.log(x));
  33. * // 1, 2, 3, 1, 2, 3, ...
  34. *
  35. * @example <caption>Throws a new error when the source Observable throws an error</caption>
  36. *
  37. * Observable.of(1, 2, 3, 4, 5)
  38. * .map(n => {
  39. * if (n == 4) {
  40. * throw 'four!';
  41. * }
  42. * return n;
  43. * })
  44. * .catch(err => {
  45. * throw 'error in source. Details: ' + err;
  46. * })
  47. * .subscribe(
  48. * x => console.log(x),
  49. * err => console.log(err)
  50. * );
  51. * // 1, 2, 3, error in source. Details: four!
  52. *
  53. * @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
  54. * is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
  55. * is returned by the `selector` will be used to continue the observable chain.
  56. * @return {Observable} An observable that originates from either the source or the observable returned by the
  57. * catch `selector` function.
  58. * @method catch
  59. * @name catch
  60. * @owner Observable
  61. */
  62. export function _catch(selector) {
  63. return higherOrder(selector)(this);
  64. }
  65. //# sourceMappingURL=catch.js.map