Exemplo n.º 1
0
 /// <summary>
 /// Allow user to report an exception even though the program doesn't need to exit
 /// </summary>
 public static void ReportNonFatalException(Exception exception, IRepeatNoticePolicy policy)
 {
     if (s_justRecordNonFatalMessagesForTesting)
     {
         ErrorReport.s_previousNonFatalException = exception;
         return;
     }
     _errorReporter.ReportNonFatalException(exception, policy);
     UsageReporter.ReportException(false, null, exception, null);
 }
Exemplo n.º 2
0
		/// <summary>
		///
		/// </summary>
		/// <example>
		/// UsageReporter.Init(Settings.Default.Reporting, "myproduct.org", "UA-11111111-2",
		///#if DEBUG
		///                true
		///#else
		///                false
		///#endif
		///                );
		/// </example>
		/// <param name="settings"></param>
		/// <param name="domain"></param>
		/// <param name="googleAnalyticsAccountCode"></param>
		/// <param name="reportAsDeveloper">Normally this is true for DEBUG builds. It is separated out here because sometimes a developer
		/// uses a Release build of Palaso.dll, but would still want his/her activities logged as a developer.</param>
		public static void Init(ReportingSettings settings, string domain, string googleAnalyticsAccountCode, bool reportAsDeveloper)
		{
			s_singleton = new UsageReporter();
			s_singleton._settings = settings;
			s_singleton._realPreviousVersion = settings.PreviousVersion;
			s_singleton._settings.Launches++;
			s_singleton.BeginGoogleAnalytics(domain, googleAnalyticsAccountCode, reportAsDeveloper);
			settings.PreviousVersion = ErrorReport.VersionNumberString;
			settings.PreviousLaunchDate = DateTime.Now.Date;
			s_singleton._mostRecentArea = "Initializing"; // Seems more useful to put in something in case an error occurs before app gets this set.
		}
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <example>
 /// UsageReporter.Init(Settings.Default.Reporting, "myproduct.org", "UA-11111111-2",
 ///#if DEBUG
 ///                true
 ///#else
 ///                false
 ///#endif
 ///                );
 /// </example>
 /// <param name="settings"></param>
 /// <param name="domain"></param>
 /// <param name="googleAnalyticsAccountCode"></param>
 /// <param name="reportAsDeveloper">Normally this is true for DEBUG builds. It is separated out here because sometimes a developer
 /// uses a Release build of Palaso.dll, but would still want his/her activities logged as a developer.</param>
 public static void Init(ReportingSettings settings, string domain, string googleAnalyticsAccountCode, bool reportAsDeveloper)
 {
     s_singleton                      = new UsageReporter();
     s_singleton._settings            = settings;
     s_singleton._realPreviousVersion = settings.PreviousVersion;
     s_singleton._settings.Launches++;
     s_singleton.BeginGoogleAnalytics(domain, googleAnalyticsAccountCode, reportAsDeveloper);
     settings.PreviousVersion    = ErrorReport.VersionNumberString;
     settings.PreviousLaunchDate = DateTime.Now.Date;
     s_singleton._mostRecentArea = "Initializing";                     // Seems more useful to put in something in case an error occurs before app gets this set.
 }
Exemplo n.º 4
0
        public static void NotifyUserOfProblem(IRepeatNoticePolicy policy, Exception error, string messageFmt, params object[] args)
        {
            var result = NotifyUserOfProblem(policy, "Details", ErrorResult.Yes, messageFmt, args);

            if (result == ErrorResult.Yes)
            {
                ErrorReport.ReportNonFatalExceptionWithMessage(error, string.Format(messageFmt, args));
            }

            UsageReporter.ReportException(false, null, error, String.Format(messageFmt, args));
        }
Exemplo n.º 5
0
 public static void ReportFatalException(Exception error)
 {
     UsageReporter.ReportException(true, null, error, null);
     _errorReporter.ReportFatalException(error);
 }
        public void Report(string message, string messageBeforeStack, Exception error, Form owningForm)
        {
            try
            {
                if (!string.IsNullOrEmpty(message))
                {
                    UsageReporter.ReportExceptionString(message);
                }
                else if (error != null)
                {
                    UsageReporter.ReportException(error);
                }
            }
            catch
            {
                //swallow
            }

            if (!string.IsNullOrEmpty(message))
            {
                Console.WriteLine("Message (not an exception): " + message);
                _details += "Message (not an exception): " + message + Environment.NewLine;
                _details += Environment.NewLine;
            }
            if (!string.IsNullOrEmpty(messageBeforeStack))
            {
                Console.WriteLine(messageBeforeStack);
                _details += messageBeforeStack;
                _details += Environment.NewLine;
            }

            Exception innerMostException = null;

            _details += ErrorReport.GetHiearchicalExceptionInfo(error, ref innerMostException);
            Console.WriteLine(ErrorReport.GetHiearchicalExceptionInfo(error, ref innerMostException));

            //if the exception had inner exceptions, show the inner-most exception first, since that is usually the one
            //we want the developer to read.
            if (innerMostException != null)
            {
                _details += "Inner-most exception:\r\n" + ErrorReport.GetExceptionText(innerMostException) +
                            "\r\n\r\nFull, hierarchical exception contents:\r\n" + _details;
                Console.WriteLine("Inner-most exception:\r\n" + ErrorReport.GetExceptionText(innerMostException) +
                                  "\r\n\r\nFull, hierarchical exception contents:\r\n");
            }

            AddErrorReportingPropertiesToDetails();


            Debug.WriteLine(_details);
            if (innerMostException != null)
            {
                error = innerMostException;
            }


            try
            {
                Logger.WriteEvent("Got exception " + error.GetType().Name);
            }
            catch (Exception err)
            {
                //We have more than one report of dieing while logging an exception.
                Console.WriteLine("****Could not write to log (" + err.Message + ")");
                _details += "****Could not write to log (" + err.Message + ")" + Environment.NewLine;
                Console.WriteLine("****Could not write to log (" + err.Message + ")");
                _details += "Was trying to log the exception: " + error.Message + Environment.NewLine;
                Console.WriteLine("Recent events:");
                _details += "Recent events:" + Environment.NewLine;
                Console.WriteLine(Logger.MinorEventsLog);
                _details += Logger.MinorEventsLog;
            }

            ShowReportDialogIfAppropriate(owningForm);
        }