Ejemplo n.º 1
0
        private static void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs e)
        {
            Logger.Error("ApplicationOnThreadException", e.Exception);
            LogManager.Default.Flush();

            Application.Exit();
        }
Ejemplo n.º 2
0
        private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            DialogResult result = DialogResult.Abort;
            try
            {
                Logging.LogException(e.Exception);
                string errorMsg = "An application error occurred. Please contact the author with the following information:\n\n";
                errorMsg = errorMsg + e.Exception;
                result = MessageBox.Show(errorMsg, "Error", MessageBoxButtons.AbortRetryIgnore,
                   MessageBoxIcon.Stop);
            }
            catch (Exception fe)
            {
                try
                {
                    MessageBox.Show(fe.ToString(), "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                finally
                {
                    Application.Exit();
                }
            }

            // Exits the program when the user clicks Abort.
            if (result == DialogResult.Abort)
                Application.Exit();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// UIs the thread exception.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="t">The <see cref="ThreadExceptionEventArgs"/> instance containing the event data.</param>
        private static void UiThreadException(object sender, ThreadExceptionEventArgs t)
        {
            try
            {
                MessageBox.Show(Resources.Program_UiThreadException);
            }
            catch
            {
                try
                {
                    MessageBox.Show(
                        Resources.Program_UiThreadException_Fatal_exception_happend_inside_UIThreadException_handler,
                        Resources.Program_UiThreadException_Fatal_Windows_Forms_Error,
                        MessageBoxButtons.AbortRetryIgnore,
                        MessageBoxIcon.Stop);
                }
                finally
                {
                    Application.Exit();
                }
            }

            // Here we can decide if we want to end our application or do something else
            Application.Exit();
        }
Ejemplo n.º 4
0
        public static void UIThreadException(object sender, ThreadExceptionEventArgs e)
        {
            Logger.Write(LogType.Error, Localization.Text_UIException, Environment.NewLine + e.Exception.ToString());

            DialogResult dialogResult = DialogResult.OK;

            try
            {
                dialogResult = ShowException(ExceptionType.Unhandled, Localization.Name_UIException, e.Exception.Message, e.Exception.ToString(), true);
            }
            catch
            {
                try
                {
                    MessageBox.Show(Localization.Text_FatalWindowsForms, Localization.Text_FatalWindowsForms, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                }
                finally
                {
                    Environment.Exit(1);
                }
            }

            if (dialogResult == DialogResult.Abort)
            {
                Environment.Exit(1);
            }
        }
Ejemplo n.º 5
0
        // Handle the UI exceptions by showing a dialog box, and asking the user whether 
        // or not they wish to abort execution. 
        private static void MainWnd_UIThreadException(object sender, ThreadExceptionEventArgs t)
        {
            DialogResult result = DialogResult.Cancel;
            try
            {
                Event clsEvent = new Event();
                clsEvent.AddErrorEventLn(t.Exception);

                result = ShowThreadExceptionDialog("Windows Forms Error", t.Exception);
            }
            catch
            {
                try
                {
                    MessageBox.Show("Fatal Windows Forms Error", "Fatal Windows Forms Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
                }
                finally
                {
                    Application.Exit();
                }
            }

            // Exits the program when the user clicks Abort. 
            if (result == DialogResult.Abort)
                Application.Exit();
        }
Ejemplo n.º 6
0
 private static void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs e)
 {
     MessageBox.Show(e.Exception.Message,
                     Application.ProductName,
                     MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
 }
Ejemplo n.º 7
0
 static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e)
 {
     if (e != null)
     {
         WriteError(e.Exception);
     }
 }
        ///// <summary>
        ///// Used for handling System.Threading.Tasks bound to a background worker thread.
        ///// Handles the <see cref="UnobservedTaskException"/> event in <see cref="System.Threading.Tasks"/> namespace.
        ///// </summary>
        //public static EventHandler<UnobservedTaskExceptionEventArgs> UnobservedTaskException
        //{
        //    get
        //    {
        //    }
        //}

        /// <summary>
        /// Used for handling WinForms exceptions bound to the UI thread.
        /// Handles the <see cref="Application.ThreadException"/> events in <see cref="System.Windows.Forms"/> namespace.
        /// </summary>
        /// <param name="sender">Exception sender object.</param>
        /// <param name="e">Real exception is in: e.Exception</param>
        private static void ThreadExceptionHandler(object sender, ThreadExceptionEventArgs e)
        {
            //regular exception handling logic...


            InitializeReport(e.Exception, Assembly.GetCallingAssembly());
        }
Ejemplo n.º 9
0
            // Handles the exception event.
            public void OnThreadException(object sender, ThreadExceptionEventArgs t)
            {
                DialogResult result = System.Windows.Forms.DialogResult.Cancel;
                try
                {
                    result = this.ShowThreadExceptionDialog(t.Exception);
                }
                catch
                {
                    try
                    {
                        MessageBox.Show("Fatal Error", "Fatal Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
                    }
                    finally
                    {
                        Application.Exit();
                    }
                }

                // Exits the program when the user clicks Abort.
                if (result == System.Windows.Forms.DialogResult.Abort)
                {
                    //					if (frm.SaveModel(true))
                    //					{
                    Application.Exit();
                    //					}
                }
            }
Ejemplo n.º 10
0
		private static void UIThreadException(object sender, ThreadExceptionEventArgs t)
		{
			DialogResult result = DialogResult.Cancel;
			try
			{
				Exception ex = (Exception)t.Exception;

				string errorMsg = "UIThreadException\r\n\r\n";
				errorMsg += "Oops, gInk crashed! Please include the following information if you plan to contact the developers (a copy of the following information is stored in crash.txt in the application folder):\r\n\r\n";
				errorMsg += ex.Message + "\r\n\r\n";
				errorMsg += "Stack Trace:\r\n" + ex.StackTrace + "\r\n\r\n";
				WriteErrorLog(errorMsg);

				errorMsg += "!!! PLEASE PRESS ESC KEY TO EXIT IF YOU FEEL YOUR MOUSE CLICK IS BLOCKED BY SOMETHING";
				ShowErrorDialog("UIThreadException", errorMsg);
			}
			catch
			{
				try
				{
					MessageBox.Show("Fatal Windows Forms Error", "Fatal Windows Forms Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
				}
				finally
				{
					Application.Exit();
				}
			}

			// Exits the program when the user clicks Abort.
			if (result == DialogResult.Abort)
				Application.Exit();
		}
Ejemplo n.º 11
0
 private static void PrintError(object sender, ThreadExceptionEventArgs args)
 {
     using (var writer = new StreamWriter("error.log", false))
     {
         writer.Write(args.Exception.ToString());
     }
 }
Ejemplo n.º 12
0
 // Unhandled UI exceptions (can ignore and resume)
 private static void Application_ThreadException(object sender, ThreadExceptionEventArgs t)
 {
     DialogResult result = DialogResult.Abort;
     try
     {
         if (logUiExceptionsOnly)
         {
             Console.WriteLine("EXCEPTION: " + ((Exception)t.Exception).ToString() + "");
             result = DialogResult.Ignore;
         }
         else
         {
             Exception ex = (Exception)t.Exception;
             string error =
                 "Sorry, an application error occurred (unhandled UI exception).\r\n\r\n" +
                 "Exception: " + ex.ToString() + "\r\n\r\n" +
                 "Stack trace: " + ex.StackTrace + "";
             result = MessageBox.Show(error, Application.ProductName, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
         }
     }
     catch { ; }
     finally
     {
         if (result == DialogResult.Abort) { Application.Exit(); }
     }
 }
Ejemplo n.º 13
0
 void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     string err = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
     if (e.Exception.InnerException != null)
         err += Environment.NewLine + e.Exception.InnerException.Message + Environment.NewLine + e.Exception.InnerException.StackTrace;
     txtRet.Text = err;
 }
Ejemplo n.º 14
0
 private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     // this one catches the exceptions in .NET
       ExceptionHandler eh = new ExceptionHandler();
       eh.InitializeWindow(Program.ProgramName, e.Exception, ErrorBaseUrl);
       eh.ShowDialog();
 }
Ejemplo n.º 15
0
			public static void HandleThreadException (object sender, ThreadExceptionEventArgs args)
			{
				_thisForm.Refresh ();
				Application.DoEvents ();
				HasHandledException = true;
				_thisForm.Close ();
			}
Ejemplo n.º 16
0
        /// <summary>
        /// Handle for untrapped thread exceptions.
        /// </summary>
        /// <param name="sender">
        /// Sender object.
        /// </param>
        /// <param name="t">
        /// Exception event arguments.
        /// </param>
        private static void UIThreadExceptionHandler(object sender, ThreadExceptionEventArgs t)
        {
            DialogResult result = DialogResult.Cancel;
            try
            {
                result = Program.ShowThreadExceptionDialog(t.Exception);
            }
            catch
            {
                try
                {
                    string text = "Fatal " + ErrorTitle;
                    MessageBox.Show(text, text, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
                }
                finally
                {
                    Application.Exit();
                }
            }

            // Exits the program when the user clicks Abort.
            if (result == DialogResult.Abort)
            {
                Application.Exit();
            }
        }
Ejemplo n.º 17
0
 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     if (!(e.Exception is System.Globalization.CultureNotFoundException)) // To avoid error when changing language (on some computers) - see https://github.com/SubtitleEdit/subtitleedit/issues/719
     {
         ShowThreadExceptionDialog("Unhandled exception in SubtitleEdit.exe", e.Exception);
     }
 }
Ejemplo n.º 18
0
 //线程异常处理
 private static void Application_ThreadException(object sender, ThreadExceptionEventArgs t)
 {
     if (t.Exception.InnerException != null)
         MessageBox.Show(t.Exception.InnerException.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     else
         MessageBox.Show(t.Exception.Message + "\n\n请联系管理员!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 }
Ejemplo n.º 19
0
        /**************************************************************************************
         * FUNCTION:  private static void noteUnhandledExceptionEvent(object sender, ThreatExceptionEventArgs t)
         *
         * ARGUMENTS: sender - object that is calling the function
         *            t - the event information including the exception.
         *
         * OUTPUT:   Information about the error that caused this event will be placed in the logging.txt file.
         *
         * EXIT CONDITIONS:  The program may be restarted if the user requests so, or the program may end here.
         *
         **************************************************************************************/
        private static void noteUnhandledExceptionEvent(object sender, ThreadExceptionEventArgs t)
        {
            //Create the logging file and write the error information to it.
            using(StreamWriter errorOutput = new StreamWriter("logging.txt", true) )
            {
                errorOutput.WriteLine("Exception occured on " + DateTime.Now.ToString() + " at " + t.Exception.Source
                    + " in method " + t.Exception.TargetSite);
                errorOutput.WriteLine("Data values are as follows:");
                foreach (DictionaryEntry data in t.Exception.Data)
                {
                    errorOutput.WriteLine("\t" + data.Key + ' ' + data.Value);
                }
            }

            //Let the user choose to restart the program or not.
            DialogResult answer = MessageBox.Show("An error has occured that has caused this program to crash.\n" +
                            "The reason for this was : " + t.Exception.Message + "\n" +
                            "Would you like to restart this program?", "Easy Note Error", MessageBoxButtons.YesNo);

            if (answer == DialogResult.Yes)
            {
                //Start a new process using the aboslute path to the file that was used to create this process.
                //Only works without debugging mode because it will try to use the debug exe file which will not start
                //on its own.
                Process.Start(Process.GetCurrentProcess().MainModule.FileName);
            }

            Process.GetCurrentProcess().Kill();
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Handle the exception event.
 /// </summary>
 /// <param name="sender">The sender of the Exception.</param>
 /// <param name="t">The Exception event arguments.</param>
 public void OnThreadException(object sender, ThreadExceptionEventArgs t)
 {
     if (showExceptions)
     {
         DialogResult result = DialogResult.Cancel;
         try
         {
             result = this.ShowThreadExceptionDialog(t.Exception);
         }
         catch
         {
             try
             {
                 MessageBox.Show("Fatal Error",
                     "Fatal Error",
                     MessageBoxButtons.AbortRetryIgnore,
                     MessageBoxIcon.Stop);
             }
             finally
             {
                 Application.Exit();
             }
         }
         if (result == DialogResult.Abort)
             Application.Exit();
     }
 }
Ejemplo n.º 21
0
 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     var message =
         e.Exception.Message + Environment.NewLine + e.Exception.Source + Environment.NewLine + e.Exception.StackTrace
         + Environment.NewLine + e.Exception.InnerException;
     new Error().Add(message);
 }
Ejemplo n.º 22
0
        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            //MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
            // here you can log the exception ...
            logger.Log(LogLevel.Debug, e.Exception.Message);

        }
Ejemplo n.º 23
0
 // Handle the UI exceptions by showing a dialog box, and asking the user whether or not they wish to abort execution.
 private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     var exc = e.Exception;
     // Ignore CultureNotFoundException to avoid error when changing language (on some computers) - see https://github.com/SubtitleEdit/subtitleedit/issues/719
     if (!(exc is System.Globalization.CultureNotFoundException))
     {
         var dr = DialogResult.Abort;
         try
         {
             var cap = "Windows Forms Thread Exception";
             var msg = "An application error occurred in Subtitle Edit." +
                       "\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" +
                       "\n\nError Message:\n" + exc.Message +
                       "\n\nStack Trace:\n" + exc.StackTrace;
             dr = MessageBox.Show(msg, cap, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
         }
         catch
         {
         }
         if (dr == DialogResult.Abort)
         {
             Application.Exit();
         }
     }
 }
Ejemplo n.º 24
0
		static void catchUIThreadException(object sender, ThreadExceptionEventArgs args)
		{
		  Exception e =  args.Exception;
	      MessageBox.Show("An unhandled thread exception has occured." + Environment.NewLine
	                     +"Error Message: " + e.Message + Environment.NewLine
	                     +"Stacktrace: " + e.StackTrace,"Unexpected Exception",MessageBoxButtons.OK,MessageBoxIcon.Error);
		}
Ejemplo n.º 25
0
        // Handle the UI exceptions by showing a dialog box, and asking the user whether or not they wish to abort execution.
        private static void UIThreadException(object sender, ThreadExceptionEventArgs t)
        {
            DialogResult result = DialogResult.Cancel;
            try
            {
                // Todo: make this translatable
                ErrorWindow.ShowErrorDialog("An unhandled exception has occurred.\nYou can continue running PKHeX, but please report this error.", t.Exception, true);
            }
            catch
            {
                try
                {
                    // Todo: make this translatable
                    MessageBox.Show("A fatal error has occurred in PKHeX, and the details could not be displayed.  Please report this to the author.", "PKHeX Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                finally
                {
                    Application.Exit();
                }
            }

            // Exits the program when the user clicks Abort.
            if (result == DialogResult.Abort)
                Application.Exit();
        }
Ejemplo n.º 26
0
 public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     LibSys.StatusBar.Error("Application ThreadException " + (e == null ? "" : ("" + e.Exception)));
     #if DEBUG
     Project.ErrorBox(null, "Application ThreadException " + (e == null ? "" : ("" + e.Exception)));
     #endif
 }
Ejemplo n.º 27
0
        // Handle the UI exceptions by showing a dialog box, and asking the user whether
        // or not they wish to abort execution.
        private static void Application_ThreadException(object sender, ThreadExceptionEventArgs t)
        {
            try
            {
                reportError(t.Exception);
            }
            catch (Exception) { }
            DialogResult result = DialogResult.Cancel;
            try
            {
                result = ShowThreadExceptionDialog("Windows Forms Error", t.Exception);
            }
            catch
            {
                try
                {
                    MessageBox.Show("Fatal Windows Forms Error",
                        "Fatal Windows Forms Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);
                }
                finally
                {
                    Application.Exit();
                }
            }

            // Exits the program when the user clicks Abort.
            if (result == DialogResult.Abort)
                Application.Exit();
        }
Ejemplo n.º 28
0
 private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     string str = GetExceptionMsg(e.Exception, e.ToString());
     Loger.Error(str);
     //MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     //LogManager.WriteLog(str);
 }
Ejemplo n.º 29
0
 private void OnThreadException(object sender, ThreadExceptionEventArgs e)
 {
     if (!this.CanIgnoreException(e.Exception))
     {
         DialogResult cancel = DialogResult.Cancel;
         try
         {
             cancel = this.ReportException(e.Exception);
         }
         catch
         {
             try
             {
                 this.ReportFatalException(e.Exception);
             }
             finally
             {
                 cancel = DialogResult.Abort;
             }
         }
         if (cancel == DialogResult.Abort)
         {
             Application.Exit();
         }
     }
 }
Ejemplo n.º 30
0
        // Handle the UI exceptions by showing a dialog box, and asking the user whether 
        // or not they wish to abort execution. 
        private static void UIThreadException(object sender, ThreadExceptionEventArgs t)
        {
            DialogResult result = DialogResult.Cancel;
            try
            {
                Log.Error(t.Exception);
                result = ShowThreadExceptionDialog("Une erreur s'est produite !", t.Exception);
            }
            catch (Exception exc)
            {
                try
                {
                    MessageBox.Show("Erreur Fatale...", "Une erreur s'est produite, mais elle n'a pas pu être écrite dans le fichier de log. Raison: "
                        + exc.Message, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                finally
                {
                    Application.Exit();
                }
            }

            // Exits the program when the user clicks Abort. 
            if (result == DialogResult.Abort)
                Application.Exit();
        }
Ejemplo n.º 31
0
 public static void ExceptionSink(object sender, System.Threading.ThreadExceptionEventArgs args)
 {
     Debug("ExceptionSink: " + args.Exception.ToString());
 }
Ejemplo n.º 32
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     MyLogger.Write(e.Exception, "Application_ThreadException", LoggingCategory.Exception);
 }
Ejemplo n.º 33
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     //   ErrorLog.Error( "系统错误"+e.Exception.ToString());
     //  XtraMessageBox.Show(e.Exception.ToString(), "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Ejemplo n.º 34
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     ShowErrorBox(e.Exception);
 }
Ejemplo n.º 35
0
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     LogHelper.WriteErrorLog("Application_ThreadException", e.Exception);
     //Thread.Sleep(5000);
     //Application.Restart();
 }
Ejemplo n.º 36
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     LogManager.LogError("Thread Exception", e.Exception);
 }
Ejemplo n.º 37
0
        private void SendThread_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            LogController <ServiceLogs> .LogInFile(ServiceLogs.ScheduledSms, string.Format("Exception Message : {0}", e.Exception.Message));

            LogController <ServiceLogs> .LogInFile(ServiceLogs.ScheduledSms, string.Format("Exception : {0}", e.Exception.StackTrace));
        }
Ejemplo n.º 38
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     // All exceptions thrown by the main thread are handled over this method
     ShowExceptionDetails(e.Exception);
 }
Ejemplo n.º 39
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     MessageBox.Show(e.Exception.Message + Environment.NewLine + e.Exception.StackTrace, "Thread exception !!",
                     MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Ejemplo n.º 40
0
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     ShowUnhandledException(e.Exception, "Application::ThreadException");
 }
Ejemplo n.º 41
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     HandleUnhandledException(e);
 }
Ejemplo n.º 42
0
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     lock (SyncRoot) {
         Process(e.Exception);
     }
 }
Ejemplo n.º 43
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     MessageBox.Show(e.Exception.ToString(), "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
 }
Ejemplo n.º 44
0
 static void ThreadUnhandledException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     Utils.OnError(null);
 }
Ejemplo n.º 45
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            string str = GetExceptionMsg(e.Exception, e.ToString());

            MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Ejemplo n.º 46
0
 private static void otherException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     FileLog.FileLogOut("DCTControlPanel.log", e.Exception.Message);
 }
Ejemplo n.º 47
0
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     //MessageBox.Show(e.Exception.Message + "\r\n" + e.Exception.StackTrace, "系统信息");
 }
Ejemplo n.º 48
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Exception ex = e.Exception;

            handleException(ex);
        }
Ejemplo n.º 49
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            string debugText = string.Format("Message: {0}{3}Source: {1}{3}Stack Trace: {2}", e.Exception.Message, e.Exception.Source, e.Exception.StackTrace, System.Environment.NewLine);

            MainForm.AddDebugInfo(new string[] { debugText });
        }
Ejemplo n.º 50
0
        //All uncaught exceptions will go here instead. We will replace the default windows popup with our own custom one and filter out what kind of exception is being thrown
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            BLIO.Log("Application_ThreadException [ " + e.Exception + " ]");
            if (e.Exception is ReminderException)
            {
                ReminderException theException = (ReminderException)e.Exception;
                BLIO.WriteError(e.Exception, "Error with this reminder (" + theException.Reminder.Name + ") !");
                ShowError(e.Exception, "Reminder error!", theException.Message);
                UCReminders.Instance.UpdateCurrentPage();
            }
            else if (e.Exception is DirectoryNotFoundException)
            {
                DirectoryNotFoundException theException = (DirectoryNotFoundException)e.Exception;
                BLIO.WriteError(theException, "Folder not found.");
                ShowError(e.Exception, e.Exception.GetType().ToString(), theException.Message);
            }

            else if (e.Exception is UnauthorizedAccessException)
            {
                UnauthorizedAccessException theException = (UnauthorizedAccessException)e.Exception;
                BLIO.WriteError(e.Exception, "Unauthorized!");
                ShowError(e.Exception, "Unauthorized!", "RemindMe is not authorized for this action.\r\nThis can be resolved by running RemindMe in administrator-mode.");
            }

            //Here we just filter out some type of exceptions and give different messages, at the bottom is the super Exception, which can be anything.
            else if (e.Exception is FileNotFoundException)
            {
                FileNotFoundException theException = (FileNotFoundException)e.Exception; //needs in instance to call .FileName
                BLIO.WriteError(theException, "Could not find the file located at \"" + theException.FileName);
                ShowError(e.Exception, "File not found.", "Could not find the file located at \"" + theException.FileName + "\"\r\nHave you moved,renamed or deleted the file?");
            }

            else if (e.Exception is System.Data.Entity.Core.EntityException)
            {
                BLIO.WriteError(e.Exception, "System.Data.Entity.Core.EntityException");
                ShowError(e.Exception, "System.Data.Entity.Core.EntityException", "There was a problem executing SQL!");
            }

            else if (e.Exception is ArgumentNullException)
            {
                BLIO.WriteError(e.Exception, "Null argument");
                ShowError(e.Exception, "Null argument", "Null argument exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is NullReferenceException)
            {
                BLIO.WriteError(e.Exception, "Null reference");
                ShowError(e.Exception, "Null reference", "Null reference exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is SQLiteException)
            {
                BLIO.WriteError(e.Exception, "SQLite Database exception");
                ShowError(e.Exception, "SQLite Database exception", "Remindme has encountered a database error!\r\nThis might or might not be on your end. It can be on your end if you modified the database file");
            }

            else if (e.Exception is PathTooLongException)
            {
                BLIO.WriteError(e.Exception, "The path to the file is too long.");
                ShowError(e.Exception, "File Path too long.", "The path to the file is too long!.");
            }

            else if (e.Exception is StackOverflowException)
            {
                BLIO.WriteError(e.Exception, "StackOverFlowException");
                ShowError(e.Exception, "StackOverFlowException", "RemindMe has encountered a stackoverflow! This is probably not your fault. Sorry!");
            }

            else if (e.Exception is OutOfMemoryException)
            {
                BLIO.WriteError(e.Exception, "Out of Memory");
                ShowError(e.Exception, "Out of Memory", "RemindMe is out of memory!");
            }
            else if (e.Exception is DbUpdateConcurrencyException)
            {
                BLIO.WriteError(e.Exception, "Database error.");
                ShowError(e.Exception, "Database error!", "Database error encountered!");
            }

            else if (e.Exception is Exception)
            {
                BLIO.WriteError(e.Exception, "Unknown exception in main.");
                ShowError(e.Exception, "Unknown", "Unknown exception in main.");
            }
        }
Ejemplo n.º 51
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Exception ex = e.Exception;

            log.Debug(ex.ToString());

            if (ex.Message == "The port is closed.")
            {
                CustomMessageBox.Show("Serial connection has been lost");
                return;
            }
            if (ex.Message == "A device attached to the system is not functioning.")
            {
                CustomMessageBox.Show("Serial connection has been lost");
                return;
            }
            if (e.Exception.GetType() == typeof(MissingMethodException))
            {
                CustomMessageBox.Show("Please Update - Some older library dlls are causing problems\n" + e.Exception.Message);
                return;
            }
            if (e.Exception.GetType() == typeof(ObjectDisposedException) || e.Exception.GetType() == typeof(InvalidOperationException)) // something is trying to update while the form, is closing.
            {
                return;                                                                                                                 // ignore
            }
            if (e.Exception.GetType() == typeof(FileNotFoundException) || e.Exception.GetType() == typeof(BadImageFormatException))     // i get alot of error from people who click the exe from inside a zip file.
            {
                CustomMessageBox.Show("You are missing some DLL's. Please extract the zip file somewhere. OR Use the update feature from the menu");
                return;
            }
            DialogResult dr = CustomMessageBox.Show("An error has occurred\n" + ex.ToString() + "\n\nReport this Error???", "Send Error", MessageBoxButtons.YesNo);

            if (DialogResult.Yes == dr)
            {
                try
                {
                    // Create a request using a URL that can receive a post.
                    WebRequest request = WebRequest.Create("http://vps.oborne.me/mail.php");
                    request.Timeout = 10000; // 10 sec
                    // Set the Method property of the request to POST.
                    request.Method = "POST";
                    // Create POST data and convert it to a byte array.
                    string postData  = "message=" + Environment.OSVersion.VersionString + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " " + Application.ProductVersion + " Exception " + ex.ToString().Replace('&', ' ').Replace('=', ' ') + " Stack: " + ex.StackTrace.ToString().Replace('&', ' ').Replace('=', ' ');
                    byte[] byteArray = Encoding.ASCII.GetBytes(postData);
                    // Set the ContentType property of the WebRequest.
                    request.ContentType = "application/x-www-form-urlencoded";
                    // Set the ContentLength property of the WebRequest.
                    request.ContentLength = byteArray.Length;
                    // Get the request stream.
                    Stream dataStream = request.GetRequestStream();
                    // Write the data to the request stream.
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    // Close the Stream object.
                    dataStream.Close();
                    // Get the response.
                    WebResponse response = request.GetResponse();
                    // Display the status.
                    Console.WriteLine(((HttpWebResponse)response).StatusDescription);
                    // Get the stream containing content returned by the server.
                    dataStream = response.GetResponseStream();
                    // Open the stream using a StreamReader for easy access.
                    StreamReader reader = new StreamReader(dataStream);
                    // Read the content.
                    string responseFromServer = reader.ReadToEnd();
                    // Display the content.
                    Console.WriteLine(responseFromServer);
                    // Clean up the streams.
                    reader.Close();
                    dataStream.Close();
                    response.Close();
                }
                catch
                {
                    CustomMessageBox.Show("Error sending Error report!! Youre most likerly are not on the internet");
                }
            }
        }
Ejemplo n.º 52
0
 static void ApplicationThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     LogHelper.Error(e.Exception);
     ErrorReport(e.Exception.StackTrace);
 }
Ejemplo n.º 53
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     ProcessUnhandledException(sender, e.Exception, false);
 }
Ejemplo n.º 54
0
 private void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     label1.Text = e.Exception.Message;
     Thread.Sleep(2000);
 }
Ejemplo n.º 55
0
 static void HandleThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     System.Diagnostics.Trace.WriteLine(e.ToString());
 }
Ejemplo n.º 56
0
 public static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     SendDataAndShowMessage(e.Exception);
     //на этом месте можно предложить "попытать продолжить работу" (ну-ну) или закрыть приложение
     System.Windows.Forms.Application.Exit();
 }
Ejemplo n.º 57
0
 //--
 //-- handles Application.ThreadException event
 //--
 private static void ThreadExceptionHandler(System.Object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     GenericExceptionHandler(e.Exception);
 }
 //UI线程异常
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     frm_BugReport.ShowBug(e.Exception);
 }
Ejemplo n.º 59
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Util.Logging.Crash(e.Exception);

            System.Environment.Exit(-1);
        }
Ejemplo n.º 60
0
 static void GlobalEventsThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     OnThreadException(e.Exception);
 }