errors.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.WaitQueueTimeoutError = exports.PoolClearedOnNetworkError = exports.PoolClearedError = exports.PoolClosedError = void 0;
  4. const error_1 = require("../error");
  5. /**
  6. * An error indicating a connection pool is closed
  7. * @category Error
  8. */
  9. class PoolClosedError extends error_1.MongoDriverError {
  10. /**
  11. * **Do not use this constructor!**
  12. *
  13. * Meant for internal use only.
  14. *
  15. * @remarks
  16. * This class is only meant to be constructed within the driver. This constructor is
  17. * not subject to semantic versioning compatibility guarantees and may change at any time.
  18. *
  19. * @public
  20. **/
  21. constructor(pool) {
  22. super('Attempted to check out a connection from closed connection pool');
  23. this.address = pool.address;
  24. }
  25. get name() {
  26. return 'MongoPoolClosedError';
  27. }
  28. }
  29. exports.PoolClosedError = PoolClosedError;
  30. /**
  31. * An error indicating a connection pool is currently paused
  32. * @category Error
  33. */
  34. class PoolClearedError extends error_1.MongoNetworkError {
  35. /**
  36. * **Do not use this constructor!**
  37. *
  38. * Meant for internal use only.
  39. *
  40. * @remarks
  41. * This class is only meant to be constructed within the driver. This constructor is
  42. * not subject to semantic versioning compatibility guarantees and may change at any time.
  43. *
  44. * @public
  45. **/
  46. constructor(pool, message) {
  47. const errorMessage = message
  48. ? message
  49. : `Connection pool for ${pool.address} was cleared because another operation failed with: "${pool.serverError?.message}"`;
  50. super(errorMessage, pool.serverError ? { cause: pool.serverError } : undefined);
  51. this.address = pool.address;
  52. this.addErrorLabel(error_1.MongoErrorLabel.RetryableWriteError);
  53. }
  54. get name() {
  55. return 'MongoPoolClearedError';
  56. }
  57. }
  58. exports.PoolClearedError = PoolClearedError;
  59. /**
  60. * An error indicating that a connection pool has been cleared after the monitor for that server timed out.
  61. * @category Error
  62. */
  63. class PoolClearedOnNetworkError extends PoolClearedError {
  64. /**
  65. * **Do not use this constructor!**
  66. *
  67. * Meant for internal use only.
  68. *
  69. * @remarks
  70. * This class is only meant to be constructed within the driver. This constructor is
  71. * not subject to semantic versioning compatibility guarantees and may change at any time.
  72. *
  73. * @public
  74. **/
  75. constructor(pool) {
  76. super(pool, `Connection to ${pool.address} interrupted due to server monitor timeout`);
  77. }
  78. get name() {
  79. return 'PoolClearedOnNetworkError';
  80. }
  81. }
  82. exports.PoolClearedOnNetworkError = PoolClearedOnNetworkError;
  83. /**
  84. * An error thrown when a request to check out a connection times out
  85. * @category Error
  86. */
  87. class WaitQueueTimeoutError extends error_1.MongoDriverError {
  88. /**
  89. * **Do not use this constructor!**
  90. *
  91. * Meant for internal use only.
  92. *
  93. * @remarks
  94. * This class is only meant to be constructed within the driver. This constructor is
  95. * not subject to semantic versioning compatibility guarantees and may change at any time.
  96. *
  97. * @public
  98. **/
  99. constructor(message, address) {
  100. super(message);
  101. this.address = address;
  102. }
  103. get name() {
  104. return 'MongoWaitQueueTimeoutError';
  105. }
  106. }
  107. exports.WaitQueueTimeoutError = WaitQueueTimeoutError;
  108. //# sourceMappingURL=errors.js.map