Skip to content

Commit 35ea1e3

Browse files
committed
Add exception handler
1 parent 482fdc9 commit 35ea1e3

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@
327327
<system:String x:Key="clearlogfolderMessage">Are you sure you want to delete all logs?</system:String>
328328
<system:String x:Key="clearcachefolder">Clear Caches</system:String>
329329
<system:String x:Key="clearcachefolderMessage">Are you sure you want to delete all caches?</system:String>
330+
<system:String x:Key="clearfolderfailMessage">Failed to clear folders and files</system:String>
330331
<system:String x:Key="welcomewindow">Wizard</system:String>
331332
<system:String x:Key="userdatapath">User Data Location</system:String>
332333
<system:String x:Key="userdatapathToolTip">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.</system:String>

Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,15 @@ private void AskClearLogFolderConfirmation()
103103

104104
if (confirmResult == MessageBoxResult.Yes)
105105
{
106-
ClearLogFolder();
106+
try
107+
{
108+
ClearLogFolder();
109+
}
110+
catch (Exception e)
111+
{
112+
App.API.LogException(nameof(SettingsPaneAboutViewModel), "Failed to clear log folder", e);
113+
App.API.ShowMsgBox(App.API.GetTranslation("clearfolderfailMessage"));
114+
}
107115
}
108116
}
109117

@@ -118,7 +126,15 @@ private void AskClearCacheFolderConfirmation()
118126

119127
if (confirmResult == MessageBoxResult.Yes)
120128
{
121-
ClearCacheFolder();
129+
try
130+
{
131+
ClearCacheFolder();
132+
}
133+
catch (Exception e)
134+
{
135+
App.API.LogException(nameof(SettingsPaneAboutViewModel), "Failed to clear cache folder", e);
136+
App.API.ShowMsgBox(App.API.GetTranslation("clearfolderfailMessage"));
137+
}
122138
}
123139
}
124140

@@ -202,8 +218,7 @@ private static string BytesToReadableString(long bytes)
202218

203219
foreach (string order in orders)
204220
{
205-
if (bytes > max)
206-
return $"{decimal.Divide(bytes, max):##.##} {order}";
221+
if (bytes > max) return $"{decimal.Divide(bytes, max):##.##} {order}";
207222

208223
max /= scale;
209224
}

0 commit comments

Comments
 (0)