Skip to content

Commit 1a95632

Browse files
committed
Handle AggregateException
1 parent 14ffe3c commit 1a95632

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Views/PreviewPanel.xaml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,25 @@ public static string GetFolderSize(string folderPath)
216216
Main.Context.API.LogError(ClassName, $"Operation timed out while calculating folder size for {folderPath}");
217217
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
218218
}
219+
// For parallel operations, AggregateException may be thrown if any of the tasks fail
220+
catch (AggregateException ae)
221+
{
222+
switch (ae.InnerException)
223+
{
224+
case FileNotFoundException:
225+
Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}");
226+
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
227+
case UnauthorizedAccessException:
228+
Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}");
229+
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
230+
case OperationCanceledException:
231+
Main.Context.API.LogError(ClassName, $"Operation timed out while calculating folder size for {folderPath}");
232+
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
233+
default:
234+
Main.Context.API.LogException(ClassName, $"Failed to get folder size for {folderPath}", ae);
235+
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown");
236+
}
237+
}
219238
catch (Exception e)
220239
{
221240
Main.Context.API.LogException(ClassName, $"Failed to get folder size for {folderPath}", e);

0 commit comments

Comments
 (0)