From 56cc4e5b10a2949abd39a7d7119a3646fccafaec Mon Sep 17 00:00:00 2001 From: FriendlyFire Date: Fri, 1 Oct 2021 23:09:02 -0400 Subject: [PATCH] Slightly improved error messages for Github exception, version bump. --- application/GW2 Addon Manager/App/App.xaml.cs | 15 +++++++-------- .../Backend/Updating/UpdateHelpers.cs | 13 ++++++------- .../GW2 Addon Manager/Properties/AssemblyInfo.cs | 2 +- .../UI/OpeningPage/OpeningViewModel.cs | 4 ++-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/application/GW2 Addon Manager/App/App.xaml.cs b/application/GW2 Addon Manager/App/App.xaml.cs index 65403ae..034b9f1 100644 --- a/application/GW2 Addon Manager/App/App.xaml.cs +++ b/application/GW2 Addon Manager/App/App.xaml.cs @@ -70,10 +70,10 @@ void ShowUnhandledException(DispatcherUnhandledExceptionEventArgs e) e.Handled = true; LogError(logPath, e); string errmsg = "An unhandled exception occurred." + "\n" + e.Exception.Message + (e.Exception.InnerException != null ? "\n" + e.Exception.InnerException.Message : ""); - if (MessageBox.Show(errmsg, "Critical Error", MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK) - { - Application.Current.Shutdown(); - } + if (!(e?.Exception?.InnerException is WebException)) + MessageBox.Show(errmsg, "Critical Error", MessageBoxButton.OK, MessageBoxImage.Error); + + Application.Current.Shutdown(); } /// @@ -85,11 +85,10 @@ void ShowUnhandledException(UnhandledExceptionEventArgs e) LogError(logPath, e); Exception exc = (Exception) e.ExceptionObject; string errmsg = "An unhandled exception occurred." + "\n" + exc.Message + (exc.InnerException != null ? "\n" + exc.InnerException.Message : ""); - if (MessageBox.Show(errmsg, "Critical Error", MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK) - { - Application.Current.Shutdown(); - } + if (!(exc?.InnerException is WebException)) + MessageBox.Show(errmsg, "Critical Error", MessageBoxButton.OK, MessageBoxImage.Error); + Application.Current.Shutdown(); } /// diff --git a/application/GW2 Addon Manager/Backend/Updating/UpdateHelpers.cs b/application/GW2 Addon Manager/Backend/Updating/UpdateHelpers.cs index f3d94a8..bfa54c7 100644 --- a/application/GW2 Addon Manager/Backend/Updating/UpdateHelpers.cs +++ b/application/GW2 Addon Manager/Backend/Updating/UpdateHelpers.cs @@ -22,11 +22,10 @@ public static string DownloadStringFromGithubAPI(this WebClient wc, string url) try { return wc.DownloadString(url); } - catch (WebException) + catch (WebException ex) { - MessageBox.Show("Github servers returned an error; please try again in a few minutes.", "Github API Error", MessageBoxButton.OK, MessageBoxImage.Error); - Application.Current.Shutdown(); - return ""; + MessageBox.Show("Github servers returned an error; please try again in a few minutes.\n\nThe error was: " + ex.Message, "Github API Error", MessageBoxButton.OK, MessageBoxImage.Error); + throw ex; } } @@ -35,9 +34,9 @@ public static void DownloadFileFromGithubAPI(this WebClient wc, string url, stri try { wc.DownloadFile(url, destPath); } - catch (WebException) { - MessageBox.Show("Github servers returned an error; please try again in a few minutes.", "Github API Error", MessageBoxButton.OK, MessageBoxImage.Error); - Application.Current.Shutdown(); + catch (WebException ex) { + MessageBox.Show("Github servers returned an error; please try again in a few minutes.\n\nThe error was: " + ex.Message, "Github API Error", MessageBoxButton.OK, MessageBoxImage.Error); + throw ex; } } diff --git a/application/GW2 Addon Manager/Properties/AssemblyInfo.cs b/application/GW2 Addon Manager/Properties/AssemblyInfo.cs index 2514168..0ca2415 100644 --- a/application/GW2 Addon Manager/Properties/AssemblyInfo.cs +++ b/application/GW2 Addon Manager/Properties/AssemblyInfo.cs @@ -53,5 +53,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.2.0")] +[assembly: AssemblyVersion("1.4.3.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/application/GW2 Addon Manager/UI/OpeningPage/OpeningViewModel.cs b/application/GW2 Addon Manager/UI/OpeningPage/OpeningViewModel.cs index 8b4c9be..832996e 100644 --- a/application/GW2 Addon Manager/UI/OpeningPage/OpeningViewModel.cs +++ b/application/GW2 Addon Manager/UI/OpeningPage/OpeningViewModel.cs @@ -185,8 +185,8 @@ public string GamePath { if (value == _gamePath) return; SetProperty(ref _gamePath, value); - _configurationManager.UserConfig.GamePath = value; - _configurationManager.SaveConfiguration(); + + new Configuration(_configurationManager).SetGamePath(_gamePath); } } private string _gamePath;