Skip to content

Commit 9b2c112

Browse files
feat: catch errors when listCollections MONGOSH-1208 (#1280)
1 parent b357c0b commit 9b2c112

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

packages/shell-api/src/collection.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,18 +1348,22 @@ export default class Collection extends ShellApiWithMongoClass {
13481348

13491349
// @ts-expect-error waiting for driver release
13501350
if (!encryptedFields && !options.encryptedFields) {
1351-
const collectionInfos = await this._mongo._serviceProvider.listCollections(
1352-
this._database._name,
1353-
{
1354-
name: this._name
1355-
},
1356-
await this._database._baseOptions()
1357-
);
1351+
try {
1352+
const collectionInfos = await this._mongo._serviceProvider.listCollections(
1353+
this._database._name,
1354+
{
1355+
name: this._name
1356+
},
1357+
await this._database._baseOptions()
1358+
);
13581359

1359-
const encryptedFields: Document | undefined = collectionInfos?.[0]?.options?.encryptedFields;
1360+
const encryptedFields: Document | undefined = collectionInfos?.[0]?.options?.encryptedFields;
13601361

1361-
if (encryptedFields) {
1362-
encryptedFieldsOptions = { encryptedFields };
1362+
if (encryptedFields) {
1363+
encryptedFieldsOptions = { encryptedFields };
1364+
}
1365+
} catch (error) {
1366+
// pass, ignore all error messages
13631367
}
13641368
}
13651369

0 commit comments

Comments
 (0)