Skip to content

Commit 17f7d9a

Browse files
committed
fix: catch last error
1 parent 4df3cd6 commit 17f7d9a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/tools/atlas/metadata/connectCluster.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,17 @@ export class ConnectClusterTool extends AtlasToolBase {
101101
cn.searchParams.set("authSource", "admin");
102102
const connectionString = cn.toString();
103103

104+
let lastError: Error | undefined = undefined;
105+
104106
for (let i = 0; i < 20; i++) {
105107
try {
106108
await this.session.connectToMongoDB(connectionString, this.config.connectOptions);
107109
break;
108110
} catch (err: unknown) {
109111
const error = err instanceof Error ? err : new Error(String(err));
112+
113+
lastError = error;
114+
110115
logger.debug(
111116
LogId.atlasConnectFailure,
112117
"atlas-connect-cluster",
@@ -117,6 +122,10 @@ export class ConnectClusterTool extends AtlasToolBase {
117122
}
118123
}
119124

125+
if (lastError) {
126+
throw lastError;
127+
}
128+
120129
return {
121130
content: [
122131
{

0 commit comments

Comments
 (0)