Exemple #1
0
        public void ReportFatalMessageWithStackTrace(string message, object[] args)
        {
            var s     = string.Format(message, args);
            var stack = new System.Diagnostics.StackTrace(true);

            ExceptionReportingDialog.ReportMessage(s, stack, true);
        }
        internal static void ReportMessage(string message, Exception error, bool isLethal)
        {
            if (s_doIgnoreReport)
            {
                return;                            // ignore message if we are showing from a previous error
            }

            using (ExceptionReportingDialog dlg = new ExceptionReportingDialog(isLethal))
            {
                dlg.Report(message, null, error, null);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <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"></param>
        internal static void ReportException(Exception error, Form parent, bool isLethal)
        {
            if (s_doIgnoreReport)
            {
                return;                            // ignore message if we are showing from a previous error
            }

            using (ExceptionReportingDialog dlg = new ExceptionReportingDialog(isLethal))
            {
                dlg.Report(error, parent);
            }
        }
Exemple #4
0
 /// <summary>
 /// Allow user to report an exception even though the program doesn't need to exit
 /// </summary>
 public void ReportNonFatalException(Exception exception, IRepeatNoticePolicy policy)
 {
     if (policy.ShouldShowErrorReportDialog(exception))
     {
         if (ErrorReport.IsOkToInteractWithUser)
         {
             ExceptionReportingDialog.ReportException(exception, null, false);
         }
         else
         {
             throw new ErrorReport.NonFatalExceptionWouldHaveBeenMessageShownToUserException(exception);
         }
     }
 }
Exemple #5
0
        internal static void ReportMessage(string message, Exception error, bool isLethal)
        {
            if (s_doIgnoreReport)
            {
                lock (s_reportDataStack)
                {
                    s_reportDataStack.Push(new ExceptionReportingData(message, null, error,
                                                                      null, null, Thread.CurrentThread.ManagedThreadId));
                }
                return;                            // ignore message if we are showing from a previous error
            }

            using (ExceptionReportingDialog dlg = new ExceptionReportingDialog(isLethal))
            {
                dlg.Report(message, null, error, null);
            }
        }
Exemple #6
0
        protected override bool DisplayError(Exception exception)
        {
            UsageReporter.ReportException(false, null, exception, null);
            try
            {
                // To disable displaying a message box, put
                // <add key="ShowUI" value="False"/>
                // in the <appSettings> section of the .config file (see MSDN for details).
                bool showUI = ShowUI;

                if (exception.InnerException != null)
                {
                    Debug.WriteLine(string.Format("Exception: {0} {1}", exception.Message, exception.InnerException.Message));
                    Logger.WriteEvent("Exception: {0} {1}", exception.Message, exception.InnerException.Message);
                }
                else
                {
                    Debug.WriteLine(String.Format("Exception: {0}", exception.Message));
                    Logger.WriteEvent("Exception: {0}", exception.Message);
                }

                if (exception is ExternalException &&
                    (uint)(((ExternalException)exception).ErrorCode) == 0x8007000E)                        // E_OUTOFMEMORY
                {
                    if (showUI)
                    {
                        ExceptionReportingDialog.ReportException(exception);                        //, parent);
                    }
                    else
                    {
                        Trace.Fail("Out of memory");
                        //                        Trace.Assert(false, FwApp.GetResourceString("kstidMiscError"),
                        //                            FwApp.GetResourceString("kstidOutOfMemory"));
                    }
                }
                else
                {
                    Debug.Assert(exception.Message != string.Empty || exception is COMException,
                                 "Oops - we got an empty exception description. Change the code to handle that!");

                    if (showUI)
                    {
                        // bool fIsLethal = !(exception is Reporting.ConfigurationException);
                        //ErrorReporter.ReportException(exception, parent, fIsLethal);
                        ExceptionReportingDialog.ReportException(exception);
                        return(false);
                    }
                    else
                    {
                        //todo: the reporting component should do all this, too

                        /*                       Exception innerE = ExceptionHelper.GetInnerMostException(exception);
                         *                                              string strMessage = "Error: "; // FwApp.GetResourceString("kstidProgError") + FwApp.GetResourceString("kstidFatalError");
                         *                                              string strVersion;
                         *                                              Assembly assembly = Assembly.GetEntryAssembly();
                         *                                              object[] attributes = null;
                         *                                              if (assembly != null)
                         *                                                      attributes = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
                         *                                              if (attributes != null && attributes.Length > 0)
                         *                                                      strVersion = ((AssemblyFileVersionAttribute)attributes[0]).Version;
                         *                                              else
                         *                                                      strVersion = Application.ProductVersion;
                         *                                              string strReport = string.Format(
                         *                                                      "Got Exception", //"FwApp.GetResourceString("kstidGotException"),
                         *                                                      "*****@*****.**", //"FwApp.GetResourceString("kstidSupportEmail"),
                         *
                         *                                                      exception.Source, strVersion,
                         *                                                      ExceptionHelper.GetAllExceptionMessages(exception), innerE.Source,
                         *                                                      innerE.TargetSite.Name, ExceptionHelper.GetAllStackTraces(exception));
                         *                                              Trace.Assert(false, strMessage, strReport);
                         */

                        Debug.Fail(exception.Message);
                    }
                }
            }
            catch (Exception)
            {
                Debug.Fail("This error could not be reported normally: ", exception.Message);
            }
            return(true);
        }
Exemple #7
0
 public void ReportFatalException(Exception e)
 {
     ExceptionReportingDialog.ReportException(e, null);
 }
Exemple #8
0
        /// <summary>
        /// Bring up a "yellow box" that let's them send in a report, then return to the program.
        /// </summary>
        public void ReportNonFatalExceptionWithMessage(Exception error, string message, params object[] args)
        {
            var s = string.Format(message, args);

            ExceptionReportingDialog.ReportMessage(s, error, false);
        }