From 95d2a191303e7fbef3bcde28990df6a27ff521e2 Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+dineshsolanki@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:00:07 +0530 Subject: [PATCH] fix: Improve error handling and remove unnecessary async Enhanced error handling in `ProcessUtils.cs` by adding detailed error messages and throwing `InvalidOperationException`. Removed the unnecessary ` async ` keyword from `LoadGameData` in `PosterPickerViewModel.cs` as the method does not contain any async operations. --- FoliCon/Modules/utils/ProcessUtils.cs | 6 ++++-- FoliCon/ViewModels/PosterPickerViewModel.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/FoliCon/Modules/utils/ProcessUtils.cs b/FoliCon/Modules/utils/ProcessUtils.cs index 15ba418..f2477d4 100644 --- a/FoliCon/Modules/utils/ProcessUtils.cs +++ b/FoliCon/Modules/utils/ProcessUtils.cs @@ -24,8 +24,10 @@ public static void StartProcess(string path) } catch (Exception e) { - Logger.Error(e, "Failed to start process: {ExceptionMessage}", e.Message); - throw; + var detailedErrorMessage = $"Failed to start process at path: {path}. Exception: {e.Message}"; + + Logger.Error(e, detailedErrorMessage); + throw new InvalidOperationException(detailedErrorMessage, e); } } diff --git a/FoliCon/ViewModels/PosterPickerViewModel.cs b/FoliCon/ViewModels/PosterPickerViewModel.cs index 901bd47..49c0d41 100644 --- a/FoliCon/ViewModels/PosterPickerViewModel.cs +++ b/FoliCon/ViewModels/PosterPickerViewModel.cs @@ -100,7 +100,7 @@ public async Task LoadData() if (resultType == MediaTypes.Game) { - await LoadGameData(response); + LoadGameData(response); } else { @@ -177,7 +177,7 @@ private async Task GetTitleAndImages(string resultType, dynamic re }; } - private async Task LoadGameData(dynamic response) + private void LoadGameData(dynamic response) { Logger.Debug("Media Type is Game, loading images from IGDB"); Artwork[] images = response.Artworks.Values;