Example #1
0
        private void HandleException(object sender, UnhandledExceptionEventArgs e)
        {
            _server.FatalException = true;
            var ex = (Exception)e.ExceptionObject;

            LogException(ex);
            if (MyFakes.ENABLE_MINIDUMP_SENDING)
            {
                string path = Path.Combine(MyFileSystem.UserDataPath, "Minidump.dmp");
                Log.Info($"Generating minidump at {path}");
                Log.Error("Keen broke the minidump, sorry.");
                //MyMiniDump.Options options = MyMiniDump.Options.WithProcessThreadData | MyMiniDump.Options.WithThreadInfo;
                //MyMiniDump.Write(path, options, MyMiniDump.ExceptionInfo.Present);
            }
            LogManager.Flush();
            if (_config.RestartOnCrash)
            {
                Console.WriteLine("Restarting in 5 seconds.");
                Thread.Sleep(5000);
                var exe = typeof(Program).Assembly.Location;
                _config.WaitForPID = Process.GetCurrentProcess().Id.ToString();
                Process.Start(exe, _config.ToString());
            }
            else
            {
                MessageBox.Show("Torch encountered a fatal error and needs to close. Please check the logs for details.");
            }

            Process.GetCurrentProcess().Kill();
        }
Example #2
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;

            _log.Fatal(ex);
            Console.WriteLine("Exiting in 5 seconds.");
            Thread.Sleep(5000);
            if (_restartOnCrash)
            {
                var exe = typeof(Program).Assembly.Location;
                _config.WaitForPID = Process.GetCurrentProcess().Id.ToString();
                Process.Start(exe, _config.ToString());
            }
            //1627 = Function failed during execution.
            Environment.Exit(1627);
        }
Example #3
0
        private void HandleException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;

            LogException(ex);
            LogManager.Flush();
            if (_config.RestartOnCrash)
            {
                Console.WriteLine("Restarting in 5 seconds.");
                Thread.Sleep(5000);
                var exe = typeof(Program).Assembly.Location;
                _config.WaitForPID = Process.GetCurrentProcess().Id.ToString();
                Process.Start(exe, _config.ToString());
            }
            else
            {
                MessageBox.Show("Torch encountered a fatal error and needs to close. Please check the logs for details.");
            }

            Process.GetCurrentProcess().Kill();
        }