From 6231df85e011f2fdb3997d9ee2dbb6eb2238bf3f Mon Sep 17 00:00:00 2001 From: Christopher Suh Date: Fri, 17 Feb 2023 15:22:51 -0800 Subject: [PATCH] Handle undefined error when opening connection dialog (#21980) * handle undefined error when opening connection dialog * combine into else if * change log * update log message --- .../services/connection/browser/connectionWidget.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/services/connection/browser/connectionWidget.ts b/src/sql/workbench/services/connection/browser/connectionWidget.ts index f96908a5e4..eb5dcc48a7 100644 --- a/src/sql/workbench/services/connection/browser/connectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/connectionWidget.ts @@ -939,7 +939,11 @@ export class ConnectionWidget extends lifecycle.Disposable { // If account was not filled in from received configuration, select the first account. this._azureAccountDropdown.select(0); account = this._azureAccountList[0]; - accountName = account.key.accountId; + if (this._azureAccountList.length > 0) { + accountName = account.key.accountId; + } else { + this._logService.debug('fillInConnectionInputs: No accounts available'); + } } await this.onAzureAccountSelected(); @@ -959,7 +963,7 @@ export class ConnectionWidget extends lifecycle.Disposable { this._azureTenantId = account.properties.tenants[0].id; this.onAzureTenantSelected(0); } - else { + else if (accountName) { this._logService.error(`fillInConnectionInputs : Could not find any tenants for account ${accountName}`); } }).catch(err => this._logService.error(`Unexpected error populating initial Azure Account options : ${err}`));