Summary description for ErrorReporter.
Inheritance: System.Windows.Forms.Form, IFWDisposable
Exemple #1
0
		public static void MakeSuggestion(RegistryKey applicationKey, string emailAddress, Form parent)
		{
			ErrorReporter e = new ErrorReporter(false, emailAddress);
			e.m_fUserReport = true;
			e.m_fSuggestion = true;
			e.ShowDialog(applicationKey, null, parent);
			e.Closed += ModelessClosed;
		}
Exemple #2
0
		public static void ReportDuplicateGuids(RegistryKey applicationKey, string emailAddress, Form parent, string errorText)
		{
			ErrorReporter e = new ErrorReporter(false, emailAddress, true, errorText);
			e.m_fUserReport = true;
			e.ShowDialog(applicationKey, null, parent);
			e.Closed += ModelessClosed;
		}
Exemple #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// show a dialog or output to the error log, as appropriate.
		/// </summary>
		/// <param name="error">the exception you want to report</param>
		/// <param name="parent">the parent form that this error belongs to (i.e. the form
		/// show modally on)</param>
		/// <param name="isLethal">set to <c>true</c> if the error is lethal, otherwise
		/// <c>false</c>.</param>
		/// ------------------------------------------------------------------------------------
		public static void ReportException(Exception error, Form parent, bool isLethal)
		{
			// ignore message if we are showing from a previous error
			if (s_fIgnoreReport)
				return;

			// If the error has a message and a help link, then show that error
			if (!string.IsNullOrEmpty(error.HelpLink) && error.HelpLink.IndexOf("::/") > 0 &&
				!string.IsNullOrEmpty(error.Message))
			{
				s_fIgnoreReport = true; // This is presumably a hopelessly fatal error, so we
				// don't want to report any subsequent errors at all.
				// Look for the end of the basic message which will be terminated by two new lines or
				// two CRLF sequences.
				int lengthOfBasicMessage = error.Message.IndexOf("\r\n");
				if (lengthOfBasicMessage <= 0)
					lengthOfBasicMessage = error.Message.IndexOf("\n\n");
				if (lengthOfBasicMessage <= 0)
					lengthOfBasicMessage = error.Message.Length;

				int iSeparatorBetweenFileNameAndTopic = error.HelpLink.IndexOf("::/");
				string sHelpFile = error.HelpLink.Substring(0, iSeparatorBetweenFileNameAndTopic);
				string sHelpTopic = error.HelpLink.Substring(iSeparatorBetweenFileNameAndTopic + 3);

				string caption = ReportingStrings.kstidFieldWorksErrorCaption;
				string appExit = ReportingStrings.kstidFieldWorksErrorExitInfo;
				MessageBox.Show(parent, error.Message.Substring(0, lengthOfBasicMessage) + "\n" + appExit,
					caption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0,
					sHelpFile, HelpNavigator.Topic, sHelpTopic);
				if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
					Clipboard.SetDataObject(error.Message, true);
				else
					Logger.WriteError(error);
				Application.Exit();
			}

			using (ErrorReporter e = new ErrorReporter(isLethal))
			{
				e.HandleError(error, parent);
			}
		}
Exemple #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// show a dialog or output to the error log, as appropriate.
		/// </summary>
		/// <param name="error">the exception you want to report</param>
		/// <param name="applicationKey">The application registry key.</param>
		/// <param name="emailAddress">The e-mail address for reporting errors.</param>
		/// <param name="parent">the parent form that this error belongs to (i.e. the form
		/// show modally on)</param>
		/// <param name="isLethal">set to <c>true</c> if the error is lethal, otherwise
		/// <c>false</c>.</param>
		/// <returns>True if the error was lethal and the user chose to exit the application,
		/// false otherwise.</returns>
		/// ------------------------------------------------------------------------------------
		public static bool ReportException(Exception error, RegistryKey applicationKey,
			string emailAddress, Form parent, bool isLethal)
		{
			// I (TomH) think that unit tests should never show this Exception dialog.
			if (MiscUtils.RunningTests)
				throw error;

			// ignore message if we are showing from a previous error
			if (s_fIgnoreReport)
				return false;

			if (String.IsNullOrEmpty(emailAddress))
				emailAddress = "*****@*****.**";

			// If the error has a message and a help link, then show that error
			if (!string.IsNullOrEmpty(error.HelpLink) && error.HelpLink.IndexOf("::/") > 0 &&
				!string.IsNullOrEmpty(error.Message))
			{
				s_fIgnoreReport = true; // This is presumably a hopelessly fatal error, so we
				// don't want to report any subsequent errors at all.
				// Look for the end of the basic message which will be terminated by two new lines or
				// two CRLF sequences.
				int lengthOfBasicMessage = error.Message.IndexOf("\r\n\r\n");
				if (lengthOfBasicMessage <= 0)
					lengthOfBasicMessage = error.Message.IndexOf("\n\n");
				if (lengthOfBasicMessage <= 0)
					lengthOfBasicMessage = error.Message.Length;

				int iSeparatorBetweenFileNameAndTopic = error.HelpLink.IndexOf("::/");
				string sHelpFile = error.HelpLink.Substring(0, iSeparatorBetweenFileNameAndTopic);
				string sHelpTopic = error.HelpLink.Substring(iSeparatorBetweenFileNameAndTopic + 3);

				string caption = ReportingStrings.kstidFieldWorksErrorCaption;
				string appExit = ReportingStrings.kstidFieldWorksErrorExitInfo;
				// TODO-Linux: MessageBox.Show doesn't implement help
				MessageBox.Show(parent, error.Message.Substring(0, lengthOfBasicMessage) + Environment.NewLine + appExit,
					caption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0,
					sHelpFile, HelpNavigator.Topic, sHelpTopic);
				if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
					ClipboardUtils.SetDataObject(error.Message, true);
				else
					Logger.WriteError(error);
				Application.Exit();
				return true;
			}

			using (ErrorReporter e = new ErrorReporter(isLethal, emailAddress))
			{
				e.ShowDialog(applicationKey, error, parent);
				return e.m_userChoseToExit;
			}
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// show a dialog or output to the error log, as appropriate.
        /// </summary>
        /// <param name="error">the exception you want to report</param>
        /// <param name="applicationKey">The application registry key.</param>
        /// <param name="emailAddress">The e-mail address for reporting errors.</param>
        /// <param name="parent">the parent form that this error belongs to (i.e. the form
        /// show modally on)</param>
        /// <param name="isLethal">set to <c>true</c> if the error is lethal, otherwise
        /// <c>false</c>.</param>
        /// <returns>True if the error was lethal and the user chose to exit the application,
        /// false otherwise.</returns>
        /// ------------------------------------------------------------------------------------
        public static bool ReportException(Exception error, RegistryKey applicationKey,
                                           string emailAddress, Form parent, bool isLethal)
        {
            // I (TomH) think that unit tests should never show this Exception dialog.
            if (MiscUtils.RunningTests)
            {
                throw error;
            }

            // ignore message if we are showing from a previous error
            if (s_fIgnoreReport)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(emailAddress))
            {
                emailAddress = "*****@*****.**";
            }

            // If the error has a message and a help link, then show that error
            if (!string.IsNullOrEmpty(error.HelpLink) && error.HelpLink.IndexOf("::/") > 0 &&
                !string.IsNullOrEmpty(error.Message))
            {
                s_fIgnoreReport = true;                 // This is presumably a hopelessly fatal error, so we
                // don't want to report any subsequent errors at all.
                // Look for the end of the basic message which will be terminated by two new lines or
                // two CRLF sequences.
                int lengthOfBasicMessage = error.Message.IndexOf("\r\n\r\n");
                if (lengthOfBasicMessage <= 0)
                {
                    lengthOfBasicMessage = error.Message.IndexOf("\n\n");
                }
                if (lengthOfBasicMessage <= 0)
                {
                    lengthOfBasicMessage = error.Message.Length;
                }

                int    iSeparatorBetweenFileNameAndTopic = error.HelpLink.IndexOf("::/");
                string sHelpFile  = error.HelpLink.Substring(0, iSeparatorBetweenFileNameAndTopic);
                string sHelpTopic = error.HelpLink.Substring(iSeparatorBetweenFileNameAndTopic + 3);

                string caption = ReportingStrings.kstidFieldWorksErrorCaption;
                string appExit = ReportingStrings.kstidFieldWorksErrorExitInfo;
                // TODO-Linux: MessageBox.Show doesn't implement help
                MessageBox.Show(parent, error.Message.Substring(0, lengthOfBasicMessage) + Environment.NewLine + appExit,
                                caption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0,
                                sHelpFile, HelpNavigator.Topic, sHelpTopic);
                if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
                {
                    ClipboardUtils.SetDataObject(error.Message, true);
                }
                else
                {
                    Logger.WriteError(error);
                }
                Application.Exit();
                return(true);
            }

            using (ErrorReporter e = new ErrorReporter(isLethal, emailAddress))
            {
                e.ShowDialog(applicationKey, error, parent);
                return(e.m_userChoseToExit);
            }
        }