error handling for browse azure resources (#15291)

* custom error for throttling

* remove unused imports
This commit is contained in:
Alan Ren
2021-04-29 17:06:16 -07:00
committed by GitHub
parent 020bc738cc
commit 2aed4e76e3

View File

@@ -16,7 +16,6 @@ import { TreeNode } from '../treeNode';
import { AzureResourceCredentialError } from '../errors';
import { AzureResourceContainerTreeNodeBase } from './baseTreeNodes';
import { AzureResourceItemType, AzureResourceServiceNames } from '../constants';
import { AzureResourceMessageTreeNode } from '../messageTreeNode';
import { IAzureResourceTreeChangeHandler } from './treeChangeHandler';
import { IAzureResourceSubscriptionService, IAzureResourceSubscriptionFilterService } from '../../azureResource/interfaces';
import { AzureAccount } from 'azurecore';
@@ -223,7 +222,10 @@ class FlatAccountTreeNodeLoader {
if (error instanceof AzureResourceCredentialError) {
vscode.commands.executeCommand('azure.resource.signin');
}
this._nodes = [AzureResourceMessageTreeNode.create(AzureResourceErrorMessageUtil.getErrorMessage(error), this._accountNode)];
// 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 occured while loading Azure resources: {0}", errorMessage));
}
this._isLoading = false;