diff --git a/Fushigi/Program.cs b/Fushigi/Program.cs index 7379cc07..f2afb9de 100644 --- a/Fushigi/Program.cs +++ b/Fushigi/Program.cs @@ -1,4 +1,4 @@ -using Fushigi.util; +using Fushigi.util; using Fushigi.param; using Fushigi.ui; @@ -8,6 +8,8 @@ Console.SetOut(consoleWriter); Console.SetError(consoleWriter); +AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; + Console.WriteLine("Starting Fushigi v0.5..."); Console.WriteLine("Loading user settings..."); UserSettings.Load(); @@ -18,4 +20,16 @@ MainWindow window = new MainWindow(); -outputStream.Close(); \ No newline at end of file +outputStream.Close(); + +void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e) +{ + Exception? ex = e.ExceptionObject as Exception; + if (ex != null) + { + Console.WriteLine(ex.Message); + Console.WriteLine(ex.StackTrace); + } + + Environment.Exit(1); +}