errors.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.MongoCryptKMSRequestNetworkTimeoutError = exports.MongoCryptAzureKMSRequestError = exports.MongoCryptCreateEncryptedCollectionError = exports.MongoCryptCreateDataKeyError = exports.MongoCryptInvalidArgumentError = exports.defaultErrorWrapper = exports.MongoCryptError = void 0;
  4. const error_1 = require("../error");
  5. /**
  6. * @public
  7. * An error indicating that something went wrong specifically with MongoDB Client Encryption
  8. */
  9. class MongoCryptError extends error_1.MongoError {
  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(message, options = {}) {
  22. super(message, options);
  23. }
  24. get name() {
  25. return 'MongoCryptError';
  26. }
  27. }
  28. exports.MongoCryptError = MongoCryptError;
  29. const defaultErrorWrapper = (error) => new MongoCryptError(error.message, { cause: error });
  30. exports.defaultErrorWrapper = defaultErrorWrapper;
  31. /**
  32. * @public
  33. *
  34. * An error indicating an invalid argument was provided to an encryption API.
  35. */
  36. class MongoCryptInvalidArgumentError extends MongoCryptError {
  37. /**
  38. * **Do not use this constructor!**
  39. *
  40. * Meant for internal use only.
  41. *
  42. * @remarks
  43. * This class is only meant to be constructed within the driver. This constructor is
  44. * not subject to semantic versioning compatibility guarantees and may change at any time.
  45. *
  46. * @public
  47. **/
  48. constructor(message) {
  49. super(message);
  50. }
  51. get name() {
  52. return 'MongoCryptInvalidArgumentError';
  53. }
  54. }
  55. exports.MongoCryptInvalidArgumentError = MongoCryptInvalidArgumentError;
  56. /**
  57. * @public
  58. * An error indicating that `ClientEncryption.createEncryptedCollection()` failed to create data keys
  59. */
  60. class MongoCryptCreateDataKeyError extends MongoCryptError {
  61. /**
  62. * **Do not use this constructor!**
  63. *
  64. * Meant for internal use only.
  65. *
  66. * @remarks
  67. * This class is only meant to be constructed within the driver. This constructor is
  68. * not subject to semantic versioning compatibility guarantees and may change at any time.
  69. *
  70. * @public
  71. **/
  72. constructor(encryptedFields, { cause }) {
  73. super(`Unable to complete creating data keys: ${cause.message}`, { cause });
  74. this.encryptedFields = encryptedFields;
  75. }
  76. get name() {
  77. return 'MongoCryptCreateDataKeyError';
  78. }
  79. }
  80. exports.MongoCryptCreateDataKeyError = MongoCryptCreateDataKeyError;
  81. /**
  82. * @public
  83. * An error indicating that `ClientEncryption.createEncryptedCollection()` failed to create a collection
  84. */
  85. class MongoCryptCreateEncryptedCollectionError extends MongoCryptError {
  86. /**
  87. * **Do not use this constructor!**
  88. *
  89. * Meant for internal use only.
  90. *
  91. * @remarks
  92. * This class is only meant to be constructed within the driver. This constructor is
  93. * not subject to semantic versioning compatibility guarantees and may change at any time.
  94. *
  95. * @public
  96. **/
  97. constructor(encryptedFields, { cause }) {
  98. super(`Unable to create collection: ${cause.message}`, { cause });
  99. this.encryptedFields = encryptedFields;
  100. }
  101. get name() {
  102. return 'MongoCryptCreateEncryptedCollectionError';
  103. }
  104. }
  105. exports.MongoCryptCreateEncryptedCollectionError = MongoCryptCreateEncryptedCollectionError;
  106. /**
  107. * @public
  108. * An error indicating that mongodb-client-encryption failed to auto-refresh Azure KMS credentials.
  109. */
  110. class MongoCryptAzureKMSRequestError extends MongoCryptError {
  111. /**
  112. * **Do not use this constructor!**
  113. *
  114. * Meant for internal use only.
  115. *
  116. * @remarks
  117. * This class is only meant to be constructed within the driver. This constructor is
  118. * not subject to semantic versioning compatibility guarantees and may change at any time.
  119. *
  120. * @public
  121. **/
  122. constructor(message, body) {
  123. super(message);
  124. this.body = body;
  125. }
  126. get name() {
  127. return 'MongoCryptAzureKMSRequestError';
  128. }
  129. }
  130. exports.MongoCryptAzureKMSRequestError = MongoCryptAzureKMSRequestError;
  131. /** @public */
  132. class MongoCryptKMSRequestNetworkTimeoutError extends MongoCryptError {
  133. get name() {
  134. return 'MongoCryptKMSRequestNetworkTimeoutError';
  135. }
  136. }
  137. exports.MongoCryptKMSRequestNetworkTimeoutError = MongoCryptKMSRequestNetworkTimeoutError;
  138. //# sourceMappingURL=errors.js.map