errors.js 4.4 KB

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