Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve disconnected action error messages #453

Merged
merged 3 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/editors/collectionDocumentsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 database';
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}`
);
}

Expand All @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion src/editors/editorsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 database';

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);
Expand Down
2 changes: 1 addition & 1 deletion src/editors/mongoDBDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down