Skip to content

Commit 9735705

Browse files
committed
fix(1483): Missing Try Cath Block
1 parent b43465d commit 9735705

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

src/Views/Preferences.axaml.cs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,23 @@ private async void SelectShellOrTerminal(object _, RoutedEventArgs e)
298298
if (shell.Name != "Custom")
299299
{
300300
options = new FilePickerOpenOptions()
301+
{
302+
FileTypeFilter = [new FilePickerFileType(shell.Name) { Patterns = [shell.Exec] }],
303+
AllowMultiple = false,
304+
};
305+
}
306+
307+
IReadOnlyList<IStorageFile> selected = null;
308+
try
301309
{
302-
FileTypeFilter = [new FilePickerFileType(shell.Name) { Patterns = [shell.Exec] }],
303-
AllowMultiple = false,
304-
};
310+
selected = await StorageProvider.OpenFilePickerAsync(options);
311+
}
312+
catch (Exception ex)
313+
{
314+
App.RaiseException(string.Empty, $"Failed to select shell/terminal: {ex.Message}");
305315
}
306316

307-
var selected = await StorageProvider.OpenFilePickerAsync(options);
308-
if (selected.Count == 1)
317+
if (selected is { Count: 1 })
309318
{
310319
ViewModels.Preferences.Instance.ShellOrTerminalPath = selected[0].Path.LocalPath;
311320
}
@@ -328,14 +337,23 @@ private async void SelectExternalMergeTool(object _, RoutedEventArgs e)
328337
if (tool.Name != "Custom")
329338
{
330339
options = new FilePickerOpenOptions()
331-
{
332-
FileTypeFilter = [new FilePickerFileType(tool.Name) { Patterns = tool.GetPatterns() }],
333-
AllowMultiple = false,
334-
};
340+
{
341+
FileTypeFilter = [new FilePickerFileType(tool.Name) { Patterns = tool.GetPatterns() }],
342+
AllowMultiple = false,
343+
};
335344
}
336345

337-
var selected = await StorageProvider.OpenFilePickerAsync(options);
338-
if (selected.Count == 1)
346+
IReadOnlyList<IStorageFile> selected = null;
347+
try
348+
{
349+
selected = await StorageProvider.OpenFilePickerAsync(options);
350+
}
351+
catch (Exception ex)
352+
{
353+
App.RaiseException(string.Empty, $"Failed to select merge tool: {ex.Message}");
354+
}
355+
356+
if (selected is { Count: 1 })
339357
{
340358
ViewModels.Preferences.Instance.ExternalMergeToolPath = selected[0].Path.LocalPath;
341359
}

0 commit comments

Comments
 (0)