Fixing unsupported providers behavior on Async Server Tree (#23758) (#23791)

* Throwing error so that connection loading fails.

* Fixing stuff

* Fixing tests
This commit is contained in:
Aasim Khan
2023-07-12 11:36:41 -07:00
committed by GitHub
parent 90fccfda34
commit c78b7ca02f
2 changed files with 20 additions and 7 deletions

View File

@@ -1368,16 +1368,22 @@ export class ConnectionManagementService extends Disposable implements IConnecti
}); });
await this._extensionService.activateByEvent(`onConnect:${connection.providerName}`); await this._extensionService.activateByEvent(`onConnect:${connection.providerName}`);
if (this._providers.get(connection.providerName) === undefined) {
await this.handleUnsupportedProvider(connection.providerName);
throw new Error(nls.localize('connection.providerNotFound', "Connection provider '{0}' not found", connection.providerName));
}
return this._providers.get(connection.providerName).onReady.then((provider) => { return this._providers.get(connection.providerName).onReady.then((provider) => {
provider.connect(uri, connectionInfo); provider.connect(uri, connectionInfo);
this._onConnectRequestSent.fire(); this._onConnectRequestSent.fire();
// Connections are made per URI so while there may possibly be multiple editors with // Connections are made per URI so while there may possibly be multiple editors with
// that URI they all share the same state // that URI they all share the same state
const editor = this._editorService.findEditors(URI.parse(uri))[0]?.editor; const editors = this._editorService.findEditors(URI.parse(uri));
// TODO make this generic enough to handle non-SQL languages too if (editors && editors[0]?.editor) {
const language = editor instanceof QueryEditorInput && editor.state.isSqlCmdMode ? 'sqlcmd' : 'sql'; const editor = editors[0].editor;
this.doChangeLanguageFlavor(uri, language, connection.providerName); // TODO make this generic enough to handle non-SQL languages too
const language = editor instanceof QueryEditorInput && editor.state.isSqlCmdMode ? 'sqlcmd' : 'sql';
this.doChangeLanguageFlavor(uri, language, connection.providerName);
}
return true; return true;
}); });
} }
@@ -1644,7 +1650,11 @@ export class ConnectionManagementService extends Disposable implements IConnecti
}); });
// send connection request // send connection request
self.sendConnectRequest(connection, uri).catch((e) => this._logService.error(e)); self.sendConnectRequest(connection, uri).catch((e) => {
this._logService.error(e);
this._connectionStatusManager.removeConnection(uri);
reject(e);
});
}); });
} }

View File

@@ -128,7 +128,10 @@ export class TreeSelectionHandler {
} }
const selectedNode = selection[0]; const selectedNode = selection[0];
if (selectedNode instanceof ConnectionProfile && !capabilitiesService.getCapabilities(selectedNode.providerName)) { if (selectedNode instanceof ConnectionProfile && !capabilitiesService.getCapabilities(selectedNode.providerName)) {
connectionManagementService.handleUnsupportedProvider(selectedNode.providerName).catch(onUnexpectedError); // Async tree handles unsupported providers through the connection management service
if (!(tree instanceof AsyncServerTree)) {
connectionManagementService.handleUnsupportedProvider(selectedNode.providerName).catch(onUnexpectedError);
}
return; return;
} }