mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 09:35:38 -05:00
Clean up docs for connect and ConnectionResult (#19509)
* Clean up docs for connect and ConnectionResult * links * fix build * fix
This commit is contained in:
@@ -685,3 +685,9 @@ export function findSqlVersionInTargetPlatform(targetPlatform: string): number |
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function throwIfNotConnected(connectionResult: azdataType.ConnectionResult): void {
|
||||
if (!connectionResult.connected) {
|
||||
throw new Error(`${connectionResult.errorMessage} (${connectionResult.errorCode})`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,9 @@ export class PublishDatabaseDialog {
|
||||
const connProfile: azdataType.IConnectionProfile = dataSource.getConnectionProfile();
|
||||
|
||||
if (dataSource.integratedSecurity) {
|
||||
connId = (await utils.getAzdataApi()!.connection.connect(connProfile, false, false)).connectionId;
|
||||
const connResult = await utils.getAzdataApi()!.connection.connect(connProfile, false, false);
|
||||
utils.throwIfNotConnected(connResult);
|
||||
connId = connResult.connectionId!;
|
||||
}
|
||||
else {
|
||||
connId = (await utils.getAzdataApi()!.connection.openConnectionDialog(undefined, connProfile)).connectionId;
|
||||
@@ -207,7 +209,6 @@ export class PublishDatabaseDialog {
|
||||
|
||||
connId = this.connectionId;
|
||||
}
|
||||
|
||||
return await utils.getAzdataApi()!.connection.getUriForConnection(connId);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -333,7 +333,7 @@ export class DeployService {
|
||||
const connectionResult = <ConnectionResult>connection;
|
||||
if (connectionResult) {
|
||||
const connected = connectionResult !== undefined && connectionResult.connected && connectionResult.connectionId !== undefined;
|
||||
return { validated: connected, errorMessage: connected ? '' : constants.connectionFailedError(connectionResult?.errorMessage) };
|
||||
return { validated: connected, errorMessage: connected ? '' : constants.connectionFailedError(connectionResult?.errorMessage!) };
|
||||
} else {
|
||||
return { validated: false, errorMessage: constants.connectionFailedError('') };
|
||||
}
|
||||
@@ -346,7 +346,7 @@ export class DeployService {
|
||||
private async formatConnectionResult(connection: ConnectionResult | string | undefined): Promise<string> {
|
||||
const getAzdataApi = await utils.getAzdataApi();
|
||||
const connectionResult = connection !== undefined && getAzdataApi ? <ConnectionResult>connection : undefined;
|
||||
return connectionResult ? connectionResult.connectionId : <string>connection;
|
||||
return connectionResult?.connected ? connectionResult.connectionId! : <string>connection;
|
||||
}
|
||||
|
||||
public async getConnection(profile: ISqlConnectionProperties, saveConnectionAndPassword: boolean, database: string): Promise<string | undefined> {
|
||||
@@ -364,7 +364,8 @@ export class DeployService {
|
||||
if (connection) {
|
||||
const connectionResult = <ConnectionResult>connection;
|
||||
if (getAzdataApi) {
|
||||
return await getAzdataApi.connection.getUriForConnection(connectionResult.connectionId);
|
||||
utils.throwIfNotConnected(connectionResult);
|
||||
return getAzdataApi.connection.getUriForConnection(connectionResult.connectionId!);
|
||||
} else {
|
||||
return <string>connection;
|
||||
}
|
||||
|
||||
@@ -80,8 +80,9 @@ async function readConnectionString(xmlDoc: any): Promise<{ connectionId: string
|
||||
const azdataApi = utils.getAzdataApi();
|
||||
if (dataSource.integratedSecurity) {
|
||||
if (azdataApi) {
|
||||
const connection = await utils.getAzdataApi()!.connection.connect(connectionProfile, false, false);
|
||||
connId = connection.connectionId;
|
||||
const connectionResult = await utils.getAzdataApi()!.connection.connect(connectionProfile, false, false);
|
||||
utils.throwIfNotConnected(connectionResult);
|
||||
connId = connectionResult.connectionId!;
|
||||
} else {
|
||||
// TODO@chgagnon - hook up VS Code MSSQL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user