static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { string message; if (e.ExceptionObject != null) { message = "Unhandled exception:\n" + e.ExceptionObject.ToString(); } else { message = "Undefined unhandled exception occurred in application."; } Trace.WriteLine(message, "Phoenix"); if (e.ExceptionObject is Exception) { FatalExceptionDialog dlg = new FatalExceptionDialog(); dlg.Exception = (Exception)e.ExceptionObject; dlg.TryToContinueEnabled = !e.IsTerminating; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return; } } else { System.Windows.Forms.MessageBox.Show(message, "Fatal Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } Core.Terminate(); }
private void Exit(Exception e) { Trace.TraceError(e.ToString()); Trace.Flush(); FatalExceptionDialog dlg = new FatalExceptionDialog(); dlg.Exception = e; if (dlg.ShowDialog() != DialogResult.Retry) { Core.Terminate(); } else { Trace.TraceInformation("Trying to continue."); Trace.Flush(); } dlg.Dispose(); }