Octgn.OctgnApp.CurrentDomainUnhandledException C# (CSharp) Method

CurrentDomainUnhandledException() private static method

private static CurrentDomainUnhandledException ( object sender, UnhandledExceptionEventArgs e ) : void
sender object
e System.UnhandledExceptionEventArgs
return void
        private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;
            var handled = false;
            var ge = Program.GameEngine;
            var gameString = "";
            if (ge != null && ge.Definition != null)
                gameString = "[Game " + ge.Definition.Name + " " + ge.Definition.Version + " " + ge.Definition.Id + "] [Username " + Prefs.Username + "] ";
            if (ex is UserMessageException)
            {
                if ((ex as UserMessageException).Mode == UserMessageExceptionMode.Blocking || WindowManager.GrowlWindow == null)
                    ShowErrorMessageBox("Error", ex.Message);
                else
                    WindowManager.GrowlWindow.AddNotification(new ErrorNotification(ex.Message));
                //ShowErrorMessageBox("Error", ex.Message);
                Log.Warn("Unhandled Exception " + gameString, ex);
                handled = true;
            }
            else if (ex is COMException)
            {
                //var er = ex as COMException;
                //if (er.ErrorCode == 0x800706A6) // Th
                //{
                //    Log.Warn("Unhandled Exception " + gameString, ex);
                //    ShowErrorMessageBox("Error", "Your install of wine was improperly configured for OCTGN. Please make sure to follow our guidelines on our wiki.");
                //    handled = true;
                //}
            }
            else if (ex is XamlParseException)
            {
                var er = ex as XamlParseException;
                Log.Warn("unhandled exception " + gameString, ex);
                handled = true;
                ShowErrorMessageBox("Error", "There was an error. If you are using Wine(linux/mac) most likely you didn't set it up right. If you are running on windows, then you should try and repair your .net installation and/or update windows. You can also try reinstalling OCTGN.");
            }
            else if (ex is IOException && (ex as IOException).Message.Contains("not enough space"))
            {
                handled = true;
                ShowErrorMessageBox("Error", "Your computer has run out of hard drive space and OCTGN will have to shut down. Please resolve this before opening OCTGN back up again.");
            }
            if (!handled)
            {
                if (e.IsTerminating)
                    Log.Fatal("UNHANDLED EXCEPTION " + gameString, ex);
                else
                    Log.Error("UNHANDLED EXCEPTION " + gameString, ex);
            }
            if (e.IsTerminating)
            {
                if (handled)
                    ShowErrorMessageBox("Error", "We will now shut down OCTGN.\nIf this continues to happen please let us know!");
                else
                    ShowErrorMessageBox("Error", "Something unexpected happened. We will now shut down OCTGN.\nIf this continues to happen please let us know!");
                Sounds.Close();
                Application.Current.Shutdown(-1);
            }
        }