Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address PR comments
  • Loading branch information
baileympearson committed Apr 4, 2024
commit 9f872484b384a77366be27703ac7373387e4852c
8 changes: 6 additions & 2 deletions src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
UNPINNED
} from '../constants';
import {
MongoAPIError,
MongoCompatibilityError,
MongoMissingDependencyError,
MongoNetworkError,
MongoNetworkTimeoutError,
MongoParseError,
Expand Down Expand Up @@ -695,7 +695,11 @@ export class CryptoConnection extends Connection {
): Promise<Document> {
const { autoEncrypter } = this;
if (!autoEncrypter) {
throw new MongoAPIError('No AutoEncrypter available for encryption');
// TODO(NODE-6065): throw a MongoMissingDependencyError in Node V7
// @ts-expect-error No cause provided because there is no underlying error.
throw new MongoMissingDependencyError('No AutoEncrypter available for encryption', {
dependencyName: 'n/a'
});
}

const serverWireVersion = maxWireVersion(this);
Expand Down
2 changes: 1 addition & 1 deletion src/encrypter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class Encrypter {
'Auto-encryption requested, but the module is not installed. ' +
'Please add `mongodb-client-encryption` as a dependency of your project',
{
cause: mongodbClientEncryption['kModuleError'].cause,
cause: mongodbClientEncryption['kModuleError'],
dependencyName: 'mongodb-client-encryption'
}
);
Expand Down
5 changes: 3 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,9 @@ export class MongoMissingCredentialsError extends MongoAPIError {
*/
export class MongoMissingDependencyError extends MongoAPIError {
dependencyName: string;
override cause: Error;

/** @remarks This property is assigned in the `Error` constructor. */
declare cause: Error;

/**
* **Do not use this constructor!**
Expand All @@ -1025,7 +1027,6 @@ export class MongoMissingDependencyError extends MongoAPIError {
constructor(message: string, options: { cause: Error; dependencyName: string }) {
super(message, options);
this.dependencyName = options.dependencyName;
this.cause = options.cause;
}

override get name(): string {
Expand Down