Skip to content

Commit 1127f4c

Browse files
committed
fix: tests
1 parent 0286a89 commit 1127f4c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/tools/mongodb/mongodbTool.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ export abstract class MongoDBToolBase extends ToolBase {
2222
);
2323
}
2424

25-
if (this.config.connectionString) {
26-
try {
27-
await this.connectToMongoDB(this.config.connectionString);
28-
} catch (error) {
29-
logger.error(
30-
LogId.mongodbConnectFailure,
31-
"mongodbTool",
32-
`Failed to connect to MongoDB instance using the connection string from the config: ${error as string}`
33-
);
34-
throw new MongoDBError(ErrorCodes.MisconfiguredConnectionString, "Not connected to MongoDB.");
35-
}
25+
if (!this.config.connectionString) {
26+
throw new MongoDBError(ErrorCodes.NotConnectedToMongoDB, "Not connected to MongoDB");
3627
}
3728

38-
throw new MongoDBError(ErrorCodes.NotConnectedToMongoDB, "Not connected to MongoDB");
29+
try {
30+
await this.connectToMongoDB(this.config.connectionString);
31+
} catch (error) {
32+
logger.error(
33+
LogId.mongodbConnectFailure,
34+
"mongodbTool",
35+
`Failed to connect to MongoDB instance using the connection string from the config: ${error as string}`
36+
);
37+
throw new MongoDBError(ErrorCodes.MisconfiguredConnectionString, "Not connected to MongoDB.");
38+
}
3939
}
4040

41-
return this.session.serviceProvider;
41+
return this.session.serviceProvider!;
4242
}
4343

4444
protected handleError(

0 commit comments

Comments
 (0)