Add exception handling for main thread

wdym you're not supposed to just throw everything into a try catch block i have no idea what youre talking about
This commit is contained in:
pizzaboxer 2023-03-12 14:14:10 +00:00
parent 558fc4e983
commit 961d21cff9
6 changed files with 191 additions and 177 deletions

View File

@ -167,8 +167,9 @@ namespace Bloxstrap
Settings.Load();
State.Load();
}
#if !DEBUG
try
{
if (!IsUninstall && !IsFirstRun)
Updater.CheckInstalledVersion();
#endif
@ -195,7 +196,7 @@ namespace Bloxstrap
ShowMessageBox($"{ProjectName} is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances.", MessageBoxImage.Information);
new MainWindow().ShowDialog();
App.FastFlags.Save();
FastFlags.Save();
}
else if (LaunchArgs.Length > 0)
{
@ -269,10 +270,12 @@ namespace Bloxstrap
{
Logger.WriteLine("[App::OnStartup] Bootstrapper task has finished");
if (t.IsFaulted)
Logger.WriteLine("[App::OnStartup] An exception occurred when running the bootstrapper");
if (t.Exception is null)
return;
Logger.WriteLine("[App::OnStartup] An exception occurred when running the bootstrapper");
Logger.WriteLine($"[App::OnStartup] {t.Exception}");
#if DEBUG
@ -281,7 +284,7 @@ namespace Bloxstrap
var exception = t.Exception.InnerExceptions.Count >= 1 ? t.Exception.InnerExceptions[0] : t.Exception;
dialog?.ShowError($"{exception.GetType()}: {exception.Message}");
#endif
});
}, TaskScheduler.FromCurrentSynchronizationContext());
dialog?.ShowBootstrapper();
bootstrapperTask.Wait();
@ -298,6 +301,17 @@ namespace Bloxstrap
}
}
}
#if !DEBUG
}
catch (Exception ex)
{
Logger.WriteLine("[App::OnStartup] An exception occurred when running the main thread");
Logger.WriteLine($"[App::OnStartup] {ex}");
if (!IsQuiet)
Settings.Prop.BootstrapperStyle.GetNew().ShowError($"{ex.GetType()}: {ex.Message}");
}
#endif
Terminate();
}