Skip to content

Commit

Permalink
feat(AutoEncryption): improve error message for missing mongodb-clien…
Browse files Browse the repository at this point in the history
…t-encryption

Fixes NODE-2078
  • Loading branch information
daprahamian committed Aug 13, 2019
1 parent de14804 commit 583f29f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/operations/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,19 @@ function createTopology(mongoClient, topologyType, options, callback) {
// setup for client side encryption
let AutoEncrypter;
try {
AutoEncrypter = require('mongodb-client-encryption').AutoEncrypter;
require.resolve('mongodb-client-encryption');
} catch (err) {
callback(
new MongoError(
'Auto-encryption requested, but the module is not installed. Please add `mongodb-client-encryption` as a dependency of your project'
)
);

return;
}
try {
AutoEncrypter = require('mongodb-client-encryption').AutoEncrypter;
} catch (err) {
callback(err);
return;
}

Expand Down

0 comments on commit 583f29f

Please sign in to comment.