Modified UnhandleException handling

Since we're crashing at this point, calling the GUI's logging systems is moot.  Just log to Utils.Log (which goes to file) before the crash happens
This commit is contained in:
Justin Swanson 2019-10-22 23:18:16 -05:00
parent 04f9775e96
commit dcbf3b069f
2 changed files with 11 additions and 12 deletions

View File

@ -10,5 +10,16 @@ namespace Wabbajack
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
public App()
{
// Wire any unhandled crashing exceptions to log before exiting
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
// Don't do any special logging side effects
Utils.SetLoggerFn((s) => { });
Utils.Log("Uncaught error:");
Utils.Log(((Exception)e.ExceptionObject).ExceptionToString());
};
}
} }
} }

View File

@ -26,7 +26,6 @@ namespace Wabbajack
this._mwvm = new MainWindowVM(mode); this._mwvm = new MainWindowVM(mode);
var context = _mwvm.AppState; var context = _mwvm.AppState;
Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}"); Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}");
SetupHandlers();
DataContext = _mwvm; DataContext = _mwvm;
new Thread(() => new Thread(() =>
@ -68,17 +67,6 @@ namespace Wabbajack
}).Start(); }).Start();
} }
private void SetupHandlers()
{
AppDomain.CurrentDomain.UnhandledException += AppHandler;
}
private void AppHandler(object sender, UnhandledExceptionEventArgs e)
{
Utils.Log("Uncaught error:");
Utils.Log(((Exception)e.ExceptionObject).ExceptionToString());
}
internal bool ExitWhenClosing = true; internal bool ExitWhenClosing = true;
private void Window_Closing(object sender, CancelEventArgs e) private void Window_Closing(object sender, CancelEventArgs e)