From 2ab71197af9840e6f08b27ac641ba90e1c6f7e35 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Thu, 1 Dec 2022 13:27:05 -0500 Subject: [PATCH 1/2] improve disconnected error messages --- src/editors/collectionDocumentsProvider.ts | 9 ++++++--- src/editors/editorsController.ts | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/editors/collectionDocumentsProvider.ts b/src/editors/collectionDocumentsProvider.ts index 857bfff0c..dad112bf6 100644 --- a/src/editors/collectionDocumentsProvider.ts +++ b/src/editors/collectionDocumentsProvider.ts @@ -60,12 +60,15 @@ export default class CollectionViewProvider // Ensure we're still connected to the correct connection. if (connectionId !== this._connectionController.getActiveConnectionId()) { operation.isCurrentlyFetchingMoreDocuments = false; + const oldConnectionName = + this._connectionController.getSavedConnectionName(connectionId || '') || + 'the connection'; void vscode.window.showErrorMessage( - `Unable to list documents: no longer connected to ${connectionId}` + `Unable to list documents: no longer connected to ${oldConnectionName}` ); throw new Error( - `Unable to list documents: no longer connected to ${connectionId}` + `Unable to list documents: no longer connected to ${oldConnectionName}` ); } @@ -74,7 +77,7 @@ export default class CollectionViewProvider const dataservice = this._connectionController.getActiveDataService(); if (dataservice === null) { - const errorMessage = `Unable to list documents: no longer connected to ${connectionId}`; + const errorMessage = 'Unable to list documents: no longer connected'; void vscode.window.showErrorMessage(errorMessage); diff --git a/src/editors/editorsController.ts b/src/editors/editorsController.ts index af6a8307f..2f91c1f79 100644 --- a/src/editors/editorsController.ts +++ b/src/editors/editorsController.ts @@ -309,8 +309,12 @@ export default class EditorsController { // Ensure we're still connected to the correct connection. if (connectionId !== this._connectionController.getActiveConnectionId()) { + const oldConnectionName = + this._connectionController.getSavedConnectionName(connectionId || '') || + 'the connection'; + void vscode.window.showErrorMessage( - `Unable to view more documents: no longer connected to ${connectionId}` + `Unable to view more documents: no longer connected to ${oldConnectionName}` ); return Promise.resolve(false); From eba14d105cf180b376206ba70450c1c2327b8a92 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Mon, 5 Dec 2022 13:30:54 -0500 Subject: [PATCH 2/2] update type to say the database instead of the connection --- src/editors/collectionDocumentsProvider.ts | 2 +- src/editors/editorsController.ts | 2 +- src/editors/mongoDBDocumentService.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/editors/collectionDocumentsProvider.ts b/src/editors/collectionDocumentsProvider.ts index dad112bf6..59dce9a1d 100644 --- a/src/editors/collectionDocumentsProvider.ts +++ b/src/editors/collectionDocumentsProvider.ts @@ -62,7 +62,7 @@ export default class CollectionViewProvider operation.isCurrentlyFetchingMoreDocuments = false; const oldConnectionName = this._connectionController.getSavedConnectionName(connectionId || '') || - 'the connection'; + 'the database'; void vscode.window.showErrorMessage( `Unable to list documents: no longer connected to ${oldConnectionName}` ); diff --git a/src/editors/editorsController.ts b/src/editors/editorsController.ts index 2f91c1f79..caa8ed2d6 100644 --- a/src/editors/editorsController.ts +++ b/src/editors/editorsController.ts @@ -311,7 +311,7 @@ export default class EditorsController { if (connectionId !== this._connectionController.getActiveConnectionId()) { const oldConnectionName = this._connectionController.getSavedConnectionName(connectionId || '') || - 'the connection'; + 'the database'; void vscode.window.showErrorMessage( `Unable to view more documents: no longer connected to ${oldConnectionName}` diff --git a/src/editors/mongoDBDocumentService.ts b/src/editors/mongoDBDocumentService.ts index 5205ff5fe..ddcb41f14 100644 --- a/src/editors/mongoDBDocumentService.ts +++ b/src/editors/mongoDBDocumentService.ts @@ -114,7 +114,7 @@ export default class MongoDBDocumentService { this._connectionController.getActiveConnectionId(); const connectionName = connectionId ? this._connectionController.getSavedConnectionName(connectionId) - : ''; + : 'the database'; if (activeConnectionId !== connectionId) { return this._fetchDocumentFailed(