errors.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.MultiErrorReply = exports.ErrorReply = exports.ReconnectStrategyError = exports.RootNodesUnavailableError = exports.SocketClosedUnexpectedlyError = exports.DisconnectsClientError = exports.ClientOfflineError = exports.ClientClosedError = exports.ConnectionTimeoutError = exports.WatchError = exports.AbortError = void 0;
  4. class AbortError extends Error {
  5. constructor() {
  6. super('The command was aborted');
  7. }
  8. }
  9. exports.AbortError = AbortError;
  10. class WatchError extends Error {
  11. constructor() {
  12. super('One (or more) of the watched keys has been changed');
  13. }
  14. }
  15. exports.WatchError = WatchError;
  16. class ConnectionTimeoutError extends Error {
  17. constructor() {
  18. super('Connection timeout');
  19. }
  20. }
  21. exports.ConnectionTimeoutError = ConnectionTimeoutError;
  22. class ClientClosedError extends Error {
  23. constructor() {
  24. super('The client is closed');
  25. }
  26. }
  27. exports.ClientClosedError = ClientClosedError;
  28. class ClientOfflineError extends Error {
  29. constructor() {
  30. super('The client is offline');
  31. }
  32. }
  33. exports.ClientOfflineError = ClientOfflineError;
  34. class DisconnectsClientError extends Error {
  35. constructor() {
  36. super('Disconnects client');
  37. }
  38. }
  39. exports.DisconnectsClientError = DisconnectsClientError;
  40. class SocketClosedUnexpectedlyError extends Error {
  41. constructor() {
  42. super('Socket closed unexpectedly');
  43. }
  44. }
  45. exports.SocketClosedUnexpectedlyError = SocketClosedUnexpectedlyError;
  46. class RootNodesUnavailableError extends Error {
  47. constructor() {
  48. super('All the root nodes are unavailable');
  49. }
  50. }
  51. exports.RootNodesUnavailableError = RootNodesUnavailableError;
  52. class ReconnectStrategyError extends Error {
  53. constructor(originalError, socketError) {
  54. super(originalError.message);
  55. Object.defineProperty(this, "originalError", {
  56. enumerable: true,
  57. configurable: true,
  58. writable: true,
  59. value: void 0
  60. });
  61. Object.defineProperty(this, "socketError", {
  62. enumerable: true,
  63. configurable: true,
  64. writable: true,
  65. value: void 0
  66. });
  67. this.originalError = originalError;
  68. this.socketError = socketError;
  69. }
  70. }
  71. exports.ReconnectStrategyError = ReconnectStrategyError;
  72. class ErrorReply extends Error {
  73. constructor(message) {
  74. super(message);
  75. this.stack = undefined;
  76. }
  77. }
  78. exports.ErrorReply = ErrorReply;
  79. class MultiErrorReply extends ErrorReply {
  80. constructor(replies, errorIndexes) {
  81. super(`${errorIndexes.length} commands failed, see .replies and .errorIndexes for more information`);
  82. Object.defineProperty(this, "replies", {
  83. enumerable: true,
  84. configurable: true,
  85. writable: true,
  86. value: void 0
  87. });
  88. Object.defineProperty(this, "errorIndexes", {
  89. enumerable: true,
  90. configurable: true,
  91. writable: true,
  92. value: void 0
  93. });
  94. this.replies = replies;
  95. this.errorIndexes = errorIndexes;
  96. }
  97. *errors() {
  98. for (const index of this.errorIndexes) {
  99. yield this.replies[index];
  100. }
  101. }
  102. }
  103. exports.MultiErrorReply = MultiErrorReply;