|
26 | 26 | import com.microsoft.azure.toolkit.lib.auth.AzureAccount; |
27 | 27 | import com.microsoft.azure.toolkit.lib.common.bundle.AzureString; |
28 | 28 | import com.microsoft.azure.toolkit.lib.common.event.AzureEventBus; |
| 29 | +import com.microsoft.azure.toolkit.lib.common.messager.AzureMessage; |
| 30 | +import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager; |
| 31 | +import com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager; |
29 | 32 | import com.microsoft.azure.toolkit.lib.common.model.Subscription; |
30 | 33 | import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation; |
31 | 34 | import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager; |
@@ -69,15 +72,20 @@ public AzureMonitorView(Project project, @Nullable LogAnalyticsWorkspace logAnal |
69 | 72 | this.updateWorkspaceNameLabel(); |
70 | 73 | Optional.ofNullable(this.selectedWorkspace).ifPresent(w -> PropertiesComponent.getInstance().setValue(AzureMonitorManager.AZURE_MONITOR_SELECTED_WORKSPACE, w.getId())); |
71 | 74 | }); |
| 75 | + final IAzureMessager messager = AzureMessager.getMessager(); |
72 | 76 | this.subscriptionChangeListener = new AzureEventBus.EventListener(e -> { |
73 | 77 | LogAnalyticsWorkspace defaultWorkspace = null; |
74 | 78 | final Account account = Azure.az(AzureAccount.class).account(); |
75 | 79 | if (Objects.nonNull(account) && account.getSelectedSubscriptions().size() > 0) { |
76 | 80 | final Subscription subscription = account.getSelectedSubscriptions().get(0); |
77 | | - final List<LogAnalyticsWorkspace> workspaceList = Azure.az(AzureLogAnalyticsWorkspace.class) |
78 | | - .logAnalyticsWorkspaces(subscription.getId()).list().stream().toList(); |
79 | | - if (workspaceList.size() > 0) { |
80 | | - defaultWorkspace = workspaceList.get(0); |
| 81 | + try { |
| 82 | + final List<LogAnalyticsWorkspace> workspaceList = Azure.az(AzureLogAnalyticsWorkspace.class) |
| 83 | + .logAnalyticsWorkspaces(subscription.getId()).list().stream().toList(); |
| 84 | + if (workspaceList.size() > 0) { |
| 85 | + defaultWorkspace = workspaceList.get(0); |
| 86 | + } |
| 87 | + } catch (final Throwable t) { |
| 88 | + messager.error(t); |
81 | 89 | } |
82 | 90 | } |
83 | 91 | this.selectedWorkspace = defaultWorkspace; |
|
0 commit comments