Skip to content

Commit 1dbff63

Browse files
Flanker-MSFTFlanker-MSFT
authored andcommitted
Swallow exception in monitor view event bus
1 parent 7a57099 commit 1dbff63

File tree

1 file changed

+12
-4
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-monitor/src/main/java/com/microsoft/azure/toolkit/intellij/monitor/view

1 file changed

+12
-4
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-monitor/src/main/java/com/microsoft/azure/toolkit/intellij/monitor/view/AzureMonitorView.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import com.microsoft.azure.toolkit.lib.auth.AzureAccount;
2727
import com.microsoft.azure.toolkit.lib.common.bundle.AzureString;
2828
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;
2932
import com.microsoft.azure.toolkit.lib.common.model.Subscription;
3033
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
3134
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
@@ -69,15 +72,20 @@ public AzureMonitorView(Project project, @Nullable LogAnalyticsWorkspace logAnal
6972
this.updateWorkspaceNameLabel();
7073
Optional.ofNullable(this.selectedWorkspace).ifPresent(w -> PropertiesComponent.getInstance().setValue(AzureMonitorManager.AZURE_MONITOR_SELECTED_WORKSPACE, w.getId()));
7174
});
75+
final IAzureMessager messager = AzureMessager.getMessager();
7276
this.subscriptionChangeListener = new AzureEventBus.EventListener(e -> {
7377
LogAnalyticsWorkspace defaultWorkspace = null;
7478
final Account account = Azure.az(AzureAccount.class).account();
7579
if (Objects.nonNull(account) && account.getSelectedSubscriptions().size() > 0) {
7680
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);
8189
}
8290
}
8391
this.selectedWorkspace = defaultWorkspace;

0 commit comments

Comments
 (0)