Enable no-floating-promises for azurecore (#16946)

* Enable no-floating-promises for azurecore

* few more

* fix compile
This commit is contained in:
Charles Gagnon
2021-09-02 09:20:32 -07:00
committed by GitHub
parent b27bdb0027
commit f35576ae7f
19 changed files with 71 additions and 48 deletions

View File

@@ -44,7 +44,7 @@ export class AzureResourceAccountTreeNode extends AzureResourceContainerTreeNode
if (this._isClearingCache) {
subscriptions = await this._subscriptionService.getSubscriptions(this.account);
this.updateCache<azureResource.AzureResourceSubscription[]>(subscriptions);
await this.updateCache<azureResource.AzureResourceSubscription[]>(subscriptions);
this._isClearingCache = false;
} else {
subscriptions = await this.getCachedSubscriptions();
@@ -77,7 +77,7 @@ export class AzureResourceAccountTreeNode extends AzureResourceContainerTreeNode
errMsg = AzureResourceErrorMessageUtil.getErrorMessage(err);
}
if (!token) {
vscode.window.showWarningMessage(localize('azure.unableToAccessSubscription', "Unable to access subscription {0} ({1}). Please [refresh the account](command:azure.resource.signin) to try again. {2}", s.name, s.id, errMsg));
void vscode.window.showWarningMessage(localize('azure.unableToAccessSubscription', "Unable to access subscription {0} ({1}). Please [refresh the account](command:azure.resource.signin) to try again. {2}", s.name, s.id, errMsg));
return false;
}
return true;
@@ -91,7 +91,7 @@ export class AzureResourceAccountTreeNode extends AzureResourceContainerTreeNode
}
} catch (error) {
if (error instanceof AzureSubscriptionError) {
vscode.commands.executeCommand('azure.resource.signin');
void vscode.commands.executeCommand('azure.resource.signin');
}
return [AzureResourceMessageTreeNode.create(AzureResourceErrorMessageUtil.getErrorMessage(error), this)];
}

View File

@@ -45,8 +45,8 @@ export abstract class AzureResourceContainerTreeNodeBase extends AzureResourceTr
this._cacheKey = this._cacheService.generateKey(id);
}
protected updateCache<T>(cache: T): void {
this._cacheService.update<T>(this._cacheKey, cache);
protected updateCache<T>(cache: T): Promise<void> {
return this._cacheService.update<T>(this._cacheKey, cache);
}
protected getCache<T>(): T {

View File

@@ -70,9 +70,9 @@ export class ConnectionDialogTreeProvider implements vscode.TreeDataProvider<Tre
}
if (errorMessages.length > 0) {
const showAccountsAction = localize('azure.resource.tree.treeProvider.openAccountsDialog', "Show Azure accounts");
vscode.window.showErrorMessage(localize('azure.resource.tree.treeProvider.accountLoadError', "Failed to load some Azure accounts. {0}", errorMessages.join(',')), showAccountsAction).then(result => {
void vscode.window.showErrorMessage(localize('azure.resource.tree.treeProvider.accountLoadError', "Failed to load some Azure accounts. {0}", errorMessages.join(',')), showAccountsAction).then(result => {
if (result === showAccountsAction) {
vscode.commands.executeCommand('azure.resource.signin');
void vscode.commands.executeCommand('azure.resource.signin');
}
});
}

View File

@@ -68,7 +68,7 @@ export class FlatAccountTreeNode extends AzureResourceContainerTreeNodeBase {
public async getChildren(): Promise<TreeNode[]> {
if (this._isClearingCache) {
this._loader.start();
this._loader.start().catch(err => console.error('Error loading Azure FlatAccountTreeNodes ', err));
this._isClearingCache = false;
return [];
} else {
@@ -211,12 +211,12 @@ class FlatAccountTreeNodeLoader {
}
} catch (error) {
if (error instanceof AzureSubscriptionError) {
vscode.commands.executeCommand('azure.resource.signin');
void vscode.commands.executeCommand('azure.resource.signin');
}
// http status code 429 means "too many requests"
// use a custom error message for azure resource graph api throttling error to make it more actionable for users.
const errorMessage = error?.statusCode === 429 ? localize('azure.resource.throttleerror', "Requests from this account have been throttled. To retry, please select a smaller number of subscriptions.") : AzureResourceErrorMessageUtil.getErrorMessage(error);
vscode.window.showErrorMessage(localize('azure.resource.tree.loadresourceerror', "An error occurred while loading Azure resources: {0}", errorMessage));
void vscode.window.showErrorMessage(localize('azure.resource.tree.loadresourceerror', "An error occurred while loading Azure resources: {0}", errorMessage));
}
this._isLoading = false;

View File

@@ -40,7 +40,7 @@ export class FlatAzureResourceTreeProvider implements vscode.TreeDataProvider<Tr
}
if (this.resourceLoader.state === LoaderState.NotStarted) {
this.resourceLoader.start();
this.resourceLoader.start().catch(err => console.error('Error loading Azure Resources for FlatAzureResourceTreeProvider ', err));
return [AzureResourceMessageTreeNode.create(localize('azure.resource.tree.treeProvider.loadingLabel', "Loading ..."), undefined)];
}