mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 09:35:37 -05:00
Better error messages from connection failures in MSAL (#22065)
* better error messages from connection failures in MSAL\, fix typo * cleanup * pr comments * rename error interface * address pr comments * update api * fix typings * change one more typing * fix build * fix tests
This commit is contained in:
@@ -128,7 +128,7 @@ export class AccountManagementService implements IAccountManagementService {
|
||||
*/
|
||||
public addAccount(providerId: string): Promise<void> {
|
||||
const closeAction: Action = new Action('closeAddingAccount', localize('accountManagementService.close', "Close"), undefined, true);
|
||||
|
||||
const genericAccountErrorMessage = localize('addAccountFailedGenericMessage', 'Adding account failed, check Azure Accounts log for more info.')
|
||||
const loginNotification: INotification = {
|
||||
severity: Severity.Info,
|
||||
message: localize('loggingIn', "Adding account..."),
|
||||
@@ -148,13 +148,19 @@ export class AccountManagementService implements IAccountManagementService {
|
||||
if (accountResult.canceled === true) {
|
||||
return;
|
||||
} else {
|
||||
throw new Error(localize('addAccountFailedMessage', `${0} \nError Message: ${1}`, accountResult.errorCode, accountResult.errorMessage));
|
||||
if (accountResult.errorCode && accountResult.errorMessage) {
|
||||
throw new Error(localize('addAccountFailedCodeMessage', `{0} \nError Message: {1}`, accountResult.errorCode, accountResult.errorMessage));
|
||||
} else if (accountResult.errorMessage) {
|
||||
throw new Error(localize('addAccountFailedMessage', `{0}`, accountResult.errorMessage));
|
||||
} else {
|
||||
throw new Error(genericAccountErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
let result = await this._accountStore.addOrUpdate(accountResult);
|
||||
if (!result) {
|
||||
this._logService.error('adding account failed');
|
||||
throw new Error(localize('addAccountFailedGeneric', 'Adding account failed, check Azure Accounts log for more info.'));
|
||||
throw new Error(genericAccountErrorMessage);
|
||||
}
|
||||
if (result.accountAdded) {
|
||||
// Add the account to the list
|
||||
|
||||
@@ -561,7 +561,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
if (this._azureAccountDropdown) {
|
||||
this._register(styler.attachSelectBoxStyler(this._azureAccountDropdown, this._themeService));
|
||||
this._register(this._azureAccountDropdown.onDidSelect(() => {
|
||||
this.onAzureAccountSelected().catch(err => this._logService.error(`Unexpeted error handling Azure Account dropdown click : ${err}`));
|
||||
this.onAzureAccountSelected().catch(err => this._logService.error(`Unexpected error handling Azure Account dropdown click : ${err}`));
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user