Skip to content

Commit c9fcecb

Browse files
committed
ensure connect rejects if construction fails
1 parent 8cc9a6b commit c9fcecb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/legacy_wrappers/mongo_client.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ module.exports.makeLegacyMongoClient = function (baseClass) {
1515
? options
1616
: undefined;
1717
options = typeof options !== 'function' ? options : undefined;
18-
const client = new this(url, options);
19-
return maybeCallback(client.connect(callback), callback);
18+
try {
19+
const client = new this(url, options);
20+
return maybeCallback(client.connect(callback), callback);
21+
} catch (error) {
22+
return maybeCallback(() => Promise.reject(error), callback);
23+
}
2024
}
2125

2226
connect(callback) {

0 commit comments

Comments
 (0)