opusdev/vector-similarity-api
1
1import { type Document } from '../bson';2import { MongoError } from '../error';3 4/**5 * @public6 * An error indicating that something went wrong specifically with MongoDB Client Encryption7 */8export class MongoCryptError extends MongoError {9 /**10 * **Do not use this constructor!**11 *12 * Meant for internal use only.13 *14 * @remarks15 * This class is only meant to be constructed within the driver. This constructor is16 * not subject to semantic versioning compatibility guarantees and may change at any time.17 *18 * @public19 **/20 constructor(message: string, options: { cause?: Error } = {}) {21 super(message, options);22 }23 24 override get name() {25 return 'MongoCryptError';26 }27}28 29/**30 * @public31 *32 * An error indicating an invalid argument was provided to an encryption API.33 */34export class MongoCryptInvalidArgumentError extends MongoCryptError {35 /**36 * **Do not use this constructor!**37 *38 * Meant for internal use only.39 *40 * @remarks41 * This class is only meant to be constructed within the driver. This constructor is42 * not subject to semantic versioning compatibility guarantees and may change at any time.43 *44 * @public45 **/46 constructor(message: string) {47 super(message);48 }49 50 override get name() {51 return 'MongoCryptInvalidArgumentError';52 }53}54/**55 * @public56 * An error indicating that `ClientEncryption.createEncryptedCollection()` failed to create data keys57 */58export class MongoCryptCreateDataKeyError extends MongoCryptError {59 encryptedFields: Document;60 /**61 * **Do not use this constructor!**62 *63 * Meant for internal use only.64 *65 * @remarks66 * This class is only meant to be constructed within the driver. This constructor is67 * not subject to semantic versioning compatibility guarantees and may change at any time.68 *69 * @public70 **/71 constructor(encryptedFields: Document, { cause }: { cause: Error }) {72 super(`Unable to complete creating data keys: ${cause.message}`, { cause });73 this.encryptedFields = encryptedFields;74 }75 76 override get name() {77 return 'MongoCryptCreateDataKeyError';78 }79}80 81/**82 * @public83 * An error indicating that `ClientEncryption.createEncryptedCollection()` failed to create a collection84 */85export class MongoCryptCreateEncryptedCollectionError extends MongoCryptError {86 encryptedFields: Document;87 /**88 * **Do not use this constructor!**89 *90 * Meant for internal use only.91 *92 * @remarks93 * This class is only meant to be constructed within the driver. This constructor is94 * not subject to semantic versioning compatibility guarantees and may change at any time.95 *96 * @public97 **/98 constructor(encryptedFields: Document, { cause }: { cause: Error }) {99 super(`Unable to create collection: ${cause.message}`, { cause });100 this.encryptedFields = encryptedFields;101 }102 103 override get name() {104 return 'MongoCryptCreateEncryptedCollectionError';105 }106}107 108/**109 * @public110 * An error indicating that mongodb-client-encryption failed to auto-refresh Azure KMS credentials.111 */112export class MongoCryptAzureKMSRequestError extends MongoCryptError {113 /** The body of the http response that failed, if present. */114 body?: Document;115 /**116 * **Do not use this constructor!**117 *118 * Meant for internal use only.119 *120 * @remarks121 * This class is only meant to be constructed within the driver. This constructor is122 * not subject to semantic versioning compatibility guarantees and may change at any time.123 *124 * @public125 **/126 constructor(message: string, body?: Document) {127 super(message);128 this.body = body;129 }130 131 override get name(): string {132 return 'MongoCryptAzureKMSRequestError';133 }134}135 136/** @public */137export class MongoCryptKMSRequestNetworkTimeoutError extends MongoCryptError {138 override get name(): string {139 return 'MongoCryptKMSRequestNetworkTimeoutError';140 }141}142 