errors.js 912 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const MongoError = require('../core/error').MongoError;
  3. /**
  4. * An error indicating a connection pool is closed
  5. *
  6. * @property {string} address The address of the connection pool
  7. * @extends MongoError
  8. */
  9. class PoolClosedError extends MongoError {
  10. constructor(pool) {
  11. super('Attempted to check out a connection from closed connection pool');
  12. this.name = 'MongoPoolClosedError';
  13. this.address = pool.address;
  14. }
  15. }
  16. /**
  17. * An error thrown when a request to check out a connection times out
  18. *
  19. * @property {string} address The address of the connection pool
  20. * @extends MongoError
  21. */
  22. class WaitQueueTimeoutError extends MongoError {
  23. constructor(pool) {
  24. super('Timed out while checking out a connection from connection pool');
  25. this.name = 'MongoWaitQueueTimeoutError';
  26. this.address = pool.address;
  27. }
  28. }
  29. module.exports = {
  30. PoolClosedError,
  31. WaitQueueTimeoutError
  32. };