Skip to content

Commit 18504a2

Browse files
authored
fix: improve disconnected action error messages VSCODE-112 (#453)
1 parent 2fed1fd commit 18504a2

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/editors/collectionDocumentsProvider.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@ export default class CollectionViewProvider
6060
// Ensure we're still connected to the correct connection.
6161
if (connectionId !== this._connectionController.getActiveConnectionId()) {
6262
operation.isCurrentlyFetchingMoreDocuments = false;
63+
const oldConnectionName =
64+
this._connectionController.getSavedConnectionName(connectionId || '') ||
65+
'the database';
6366
void vscode.window.showErrorMessage(
64-
`Unable to list documents: no longer connected to ${connectionId}`
67+
`Unable to list documents: no longer connected to ${oldConnectionName}`
6568
);
6669

6770
throw new Error(
68-
`Unable to list documents: no longer connected to ${connectionId}`
71+
`Unable to list documents: no longer connected to ${oldConnectionName}`
6972
);
7073
}
7174

@@ -74,7 +77,7 @@ export default class CollectionViewProvider
7477
const dataservice = this._connectionController.getActiveDataService();
7578

7679
if (dataservice === null) {
77-
const errorMessage = `Unable to list documents: no longer connected to ${connectionId}`;
80+
const errorMessage = 'Unable to list documents: no longer connected';
7881

7982
void vscode.window.showErrorMessage(errorMessage);
8083

src/editors/editorsController.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,12 @@ export default class EditorsController {
309309

310310
// Ensure we're still connected to the correct connection.
311311
if (connectionId !== this._connectionController.getActiveConnectionId()) {
312+
const oldConnectionName =
313+
this._connectionController.getSavedConnectionName(connectionId || '') ||
314+
'the database';
315+
312316
void vscode.window.showErrorMessage(
313-
`Unable to view more documents: no longer connected to ${connectionId}`
317+
`Unable to view more documents: no longer connected to ${oldConnectionName}`
314318
);
315319

316320
return Promise.resolve(false);

src/editors/mongoDBDocumentService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default class MongoDBDocumentService {
114114
this._connectionController.getActiveConnectionId();
115115
const connectionName = connectionId
116116
? this._connectionController.getSavedConnectionName(connectionId)
117-
: '';
117+
: 'the database';
118118

119119
if (activeConnectionId !== connectionId) {
120120
return this._fetchDocumentFailed(

0 commit comments

Comments
 (0)