Ensure SetImageAsync exceptions are handled

This commit is contained in:
Jack251970 2025-06-12 18:51:03 +08:00
parent 8cfaeeae6b
commit 61717dcd50

View file

@ -62,13 +62,22 @@ namespace Flow.Launcher
private async Task SetImageAsync(string imagePath)
{
if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath))
try
{
Img.Visibility = Visibility.Collapsed;
return;
if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath))
{
Img.Visibility = Visibility.Collapsed;
return;
}
var imageSource = await App.API.LoadImageAsync(imagePath);
Img.Source = imageSource;
Img.Visibility = Visibility.Visible;
}
catch (Exception ex)
{
App.API.LogException(ClassName, $"Failed to load UAC dialog image: {imagePath}", ex);
Img.Visibility = Visibility.Collapsed;
}
var imageSource = await App.API.LoadImageAsync(imagePath);
Img.Source = imageSource;
}
private void KeyEsc_OnPress(object sender, ExecutedRoutedEventArgs e)