From 66f1f4c20420fa4abe6721efd4edf17589466dd0 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Thu, 11 Mar 2021 06:49:05 -0500 Subject: add handler for unhandled exceptions --- grapher/Program.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'grapher/Program.cs') diff --git a/grapher/Program.cs b/grapher/Program.cs index 485e074..894d1cd 100644 --- a/grapher/Program.cs +++ b/grapher/Program.cs @@ -19,11 +19,20 @@ namespace grapher return; } + AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler; + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new RawAcceleration()); - - GC.KeepAlive(mutex); + + GC.KeepAlive(mutex); + } + + static void GlobalUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e) + { + var ex = (Exception)e.ExceptionObject; + System.IO.File.WriteAllText("error.log", ex.ToString()); + MessageBox.Show(ex.Message, "Error"); } } } -- cgit v1.2.3