From 35ea1e33a9d7be5ff0b45897dd8f795cd21eee4f Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 1 Apr 2025 20:54:36 +0800
Subject: [PATCH] Add exception handler
---
Flow.Launcher/Languages/en.xaml | 1 +
.../ViewModels/SettingsPaneAboutViewModel.cs | 23 +++++++++++++++----
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index 6963d81c9..f96509bde 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -327,6 +327,7 @@
Are you sure you want to delete all logs?
Clear Caches
Are you sure you want to delete all caches?
+ Failed to clear folders and files
Wizard
User Data Location
User settings and installed plugins are saved in the user data folder. This location may vary depending on whether it's in portable mode or not.
diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs
index 47cb1b6c3..1cd90e613 100644
--- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs
+++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs
@@ -103,7 +103,15 @@ public partial class SettingsPaneAboutViewModel : BaseModel
if (confirmResult == MessageBoxResult.Yes)
{
- ClearLogFolder();
+ try
+ {
+ ClearLogFolder();
+ }
+ catch (Exception e)
+ {
+ App.API.LogException(nameof(SettingsPaneAboutViewModel), "Failed to clear log folder", e);
+ App.API.ShowMsgBox(App.API.GetTranslation("clearfolderfailMessage"));
+ }
}
}
@@ -118,7 +126,15 @@ public partial class SettingsPaneAboutViewModel : BaseModel
if (confirmResult == MessageBoxResult.Yes)
{
- ClearCacheFolder();
+ try
+ {
+ ClearCacheFolder();
+ }
+ catch (Exception e)
+ {
+ App.API.LogException(nameof(SettingsPaneAboutViewModel), "Failed to clear cache folder", e);
+ App.API.ShowMsgBox(App.API.GetTranslation("clearfolderfailMessage"));
+ }
}
}
@@ -202,8 +218,7 @@ public partial class SettingsPaneAboutViewModel : BaseModel
foreach (string order in orders)
{
- if (bytes > max)
- return $"{decimal.Divide(bytes, max):##.##} {order}";
+ if (bytes > max) return $"{decimal.Divide(bytes, max):##.##} {order}";
max /= scale;
}