Search in sources :

Example 1 with AzureRuntimeException

use of com.microsoft.azuretools.exception.AzureRuntimeException in project azure-tools-for-java by Microsoft.

the class AzureModule method composeName.

private static String composeName() {
    try {
        AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
        if (AuthMethodManager.getInstance().isRestoringSignIn()) {
            return BASE_MODULE_NAME + " (Signing In...)";
        }
        // not signed in
        if (azureManager == null) {
            return BASE_MODULE_NAME + " (Not Signed In)";
        }
        SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
        List<SubscriptionDetail> subscriptionDetails = subscriptionManager.getSubscriptionDetails();
        List<SubscriptionDetail> selectedSubscriptions = subscriptionDetails.stream().filter(SubscriptionDetail::isSelected).collect(Collectors.toList());
        return String.format("%s (%s)", BASE_MODULE_NAME, getAccountDescription(selectedSubscriptions));
    } catch (AzureRuntimeException e) {
        DefaultLoader.getUIHelper().showInfoNotification(ERROR_GETTING_SUBSCRIPTIONS_TITLE, ErrorEnum.getDisplayMessageByCode(e.getCode()));
    } catch (Exception e) {
        final String msg = String.format(ERROR_GETTING_SUBSCRIPTIONS_MESSAGE, e.getMessage());
        DefaultLoader.getUIHelper().showException(msg, e, ERROR_GETTING_SUBSCRIPTIONS_TITLE, false, true);
    }
    return BASE_MODULE_NAME;
}
Also used : AzureRuntimeException(com.microsoft.azuretools.exception.AzureRuntimeException) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) AzureRuntimeException(com.microsoft.azuretools.exception.AzureRuntimeException)

Aggregations

SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)1 SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)1 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)1 AzureRuntimeException (com.microsoft.azuretools.exception.AzureRuntimeException)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1