Skip to content

Commit 67a6dbe

Browse files
authored
feat: mongo: improved handling of incorrect auth data (#2594)
1 parent c256bb9 commit 67a6dbe

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/mongoClusters/tree/MongoClusterItemBase.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ export abstract class MongoClusterItemBase
8383

8484
// If authentication failed, return the error element
8585
if (!mongoClustersClient) {
86+
ext.outputChannel.appendLine(`MongoDB Clusters: Failed to authenticate with "${this.mongoCluster.name}".`);
8687
return [
8788
createGenericElement({
8889
contextValue: 'error',
8990
id: `${this.id}/error`,
9091
label: 'Failed to authenticate (click to retry)',
9192
iconPath: new vscode.ThemeIcon('error'),
92-
commandId: 'azureResourceGroups.refreshTree',
93+
commandId: 'azureDatabases.refresh',
94+
commandArgs: [this],
9395
}) as CosmosDBTreeElement,
9496
];
9597
}

src/mongoClusters/tree/MongoClusterResourceItem.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ export class MongoClusterResourceItem extends MongoClusterItemBase {
128128
mongoClustersClient = await MongoClustersClient.getClient(this.id).catch((error: Error) => {
129129
ext.outputChannel.appendLine(`Error: ${error.message}`);
130130

131-
void vscode.window.showErrorMessage(`Failed to connect: ${error.message}`);
131+
void vscode.window.showErrorMessage(`Failed to connect to "${this.mongoCluster.name}"`, {
132+
modal: true,
133+
detail: `Revisit connection details and try again.\n\nError: ${error.message}`,
134+
});
132135

133136
throw error;
134137
});

src/mongoClusters/tree/workspace/MongoClusterWorkspaceItem.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ export class MongoClusterWorkspaceItem extends MongoClusterItemBase {
9898
ext.outputChannel.appendLine('failed.');
9999
ext.outputChannel.appendLine(`Error: ${error.message}`);
100100

101-
void vscode.window.showErrorMessage(`Failed to connect: ${error.message}`);
101+
void vscode.window.showErrorMessage(`Failed to connect to "${this.mongoCluster.name}"`, {
102+
modal: true,
103+
detail: `Revisit connection details and try again.\n\nError: ${error.message}`,
104+
});
102105

103106
throw error;
104107
});

0 commit comments

Comments
 (0)