public static void Init(string emailAddress) { s_emailAddress = emailAddress; ErrorReport.AddStandardProperties(); }
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); }