/// ------------------------------------------------------------------------------------ /// <summary> /// Writes an exception and its stack trace to the log. This method will do nothing if /// Init() is not called first. /// </summary> /// ------------------------------------------------------------------------------------ public static void WriteError(Exception e) { Exception dummy; Debug.WriteLine(ExceptionHelper.GetHiearchicalExceptionInfo(e, out dummy)); if (s_theOne != null) { #if !__MonoCS__ s_theOne.WriteEventInternal(ExceptionHelper.GetHiearchicalExceptionInfo(e, out dummy)); #endif } }
private void FillInDetailsTextBox(Exception error) { if (m_fReportDuplicateGuidsASAP) { m_details.Text = m_errorText; return; } StringBuilder detailsText = new StringBuilder(); Exception innerMostException = null; if (error != null) { detailsText.AppendLine(ExceptionHelper.GetHiearchicalExceptionInfo(error, out 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) { StringBuilder innerException = new StringBuilder(); innerException.AppendLine("Inner most exception:"); innerException.AppendLine(ExceptionHelper.GetExceptionText(innerMostException)); innerException.AppendLine(); innerException.AppendLine("Full, hierarchical exception contents:"); detailsText.Insert(0, innerException.ToString()); } } detailsText.AppendLine("Additional information about the computer and project:"); foreach (string label in Palaso.Reporting.ErrorReport.Properties.Keys) { detailsText.AppendLine(label + ": " + Palaso.Reporting.ErrorReport.Properties[label]); } if (innerMostException != null) { error = innerMostException; } if (error != null) { Logger.WriteEvent("Got exception " + error.GetType().Name); } detailsText.AppendLine(Logger.LogText); Debug.WriteLine(detailsText.ToString()); m_details.Text = detailsText.ToString(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Writes <paramref name="msg"/> and an exception and its stack trace to the log. /// This method will do nothing if Init() is not called first. /// </summary> /// ------------------------------------------------------------------------------------ public static void WriteError(string msg, Exception e) { Exception dummy; var bldr = new StringBuilder(msg); if (bldr.Length > 0) { bldr.AppendLine(); } bldr.Append(ExceptionHelper.GetHiearchicalExceptionInfo(e, out dummy)); Debug.WriteLine(bldr.ToString()); if (s_theOne != null) { s_theOne.WriteEventInternal(bldr.ToString()); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the error. /// </summary> /// <param name="applicationKey">The application registry key.</param> /// <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> /// ------------------------------------------------------------------------------------ private void HandleError(RegistryKey applicationKey, Exception error, Form parent) { CheckDisposed(); // // Required for Windows Form Designer support // InitializeComponent(); // These 2 lines can be deleted after the problems with mailto have been resolved. radEmail.Enabled = false; radSelf.Checked = true; if (m_emailAddress == null) { radEmail.Enabled = false; radSelf.Checked = true; } else { // Add the e-mail address to the dialog. emailLabel.Text = String.Format(emailLabel.Text, m_emailAddress); } if (!m_isLethal) { btnClose.Text = ReportingStrings.ks_Ok; BackColor = Color.FromArgb(255, 255, 192); //yellow m_notification.BackColor = BackColor; UpdateCrashCount(applicationKey, "NumberOfAnnoyingCrashes"); } else { UpdateCrashCount(applicationKey, "NumberOfSeriousCrashes"); } UpdateAppRuntime(applicationKey); StringBuilder detailsText = new StringBuilder(); Exception innerMostException; detailsText.AppendLine(ExceptionHelper.GetHiearchicalExceptionInfo(error, out 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) { StringBuilder innerException = new StringBuilder(); innerException.AppendLine("Inner most exception:"); innerException.AppendLine(ExceptionHelper.GetExceptionText(innerMostException)); innerException.AppendLine(); innerException.AppendLine("Full, hierarchical exception contents:"); detailsText.Insert(0, innerException.ToString()); } detailsText.AppendLine("Error Reporting Properties:"); foreach (string label in s_properties.Keys) { detailsText.AppendLine(label + ": " + s_properties[label]); } if (innerMostException != null) { error = innerMostException; } Logger.WriteEvent("Got exception " + error.GetType().Name); detailsText.AppendLine(Logger.LogText); Debug.WriteLine(detailsText.ToString()); m_details.Text = detailsText.ToString(); if (s_isOkToInteractWithUser) { s_fIgnoreReport = true; ShowDialog((parent != null && !parent.IsDisposed) ? parent : null); s_fIgnoreReport = false; } else //the test environment already prohibits dialogs but will save the contents of assertions in some log. { Debug.Fail(m_details.Text); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shows the dialog (handles the error, if it is one). /// </summary> /// <param name="applicationKey">The application registry key.</param> /// <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> /// ------------------------------------------------------------------------------------ private void ShowDialog(RegistryKey applicationKey, Exception error, Form parent) { CheckDisposed(); // // Required for Windows Form Designer support // InitializeComponent(); SetDialogStringsSoLocatilizationWorks(); m_viewDetailsOriginalText = viewDetailsLink.Text; m_originalHeightWithoutDetails = Height - m_details.Height - 10; m_originalHeight = Height; m_originalMinSize = MinimumSize; if (m_fUserReport) { ControlBox = true; cancelButton.Visible = true; btnClose.Size = cancelButton.Size; btnClose.Left = cancelButton.Left - btnClose.Width - 15; if (m_fSuggestion) { Text = ReportingStrings.kstidMakeSuggestionCaption; m_notification.Text = ReportingStrings.kstidMakeSuggestionNotification; m_stepsLabel.Text = ReportingStrings.kstidGoalAndSuggestion; m_reproduce.Text = ReportingStrings.kstidSampleSuggestion; } else { Text = ReportingStrings.kstidReportProblemCaption; m_notification.Text = ReportingStrings.kstidReportProblemNotification; m_stepsLabel.Text = ReportingStrings.kstidProblemAndSteps; m_reproduce.Text = ReportingStrings.ksSampleProblemReport; } // Do this AFTER filling in the sample...it is disabled until they change something. btnClose.Enabled = false; } s_showDetails = true; // the resource-file state of the dialog is showing. if (m_emailAddress == null) { radEmail.Enabled = false; radSelf.Checked = true; } else { // Add the e-mail address to the dialog. lbl_EmailReport.Text = String.Format(lbl_EmailReport.Text, m_emailAddress); } if (!m_isLethal) { btnClose.Text = ReportingStrings.ks_Ok; BackColor = m_fSuggestion ? Color.FromKnownColor(KnownColor.Control) // standard dialog background : Color.FromArgb(255, 255, 192); //yellow m_notification.BackColor = BackColor; UpdateCrashCount(applicationKey, "NumberOfAnnoyingCrashes"); } else { UpdateCrashCount(applicationKey, "NumberOfSeriousCrashes"); } UpdateAppRuntime(applicationKey); StringBuilder detailsText = new StringBuilder(); Exception innerMostException = null; if (error != null) { detailsText.AppendLine(ExceptionHelper.GetHiearchicalExceptionInfo(error, out 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) { StringBuilder innerException = new StringBuilder(); innerException.AppendLine("Inner most exception:"); innerException.AppendLine(ExceptionHelper.GetExceptionText(innerMostException)); innerException.AppendLine(); innerException.AppendLine("Full, hierarchical exception contents:"); detailsText.Insert(0, innerException.ToString()); } } detailsText.AppendLine("Additional information about the computer and project:"); foreach (string label in s_properties.Keys) { detailsText.AppendLine(label + ": " + s_properties[label]); } if (innerMostException != null) { error = innerMostException; } if (error != null) { Logger.WriteEvent("Got exception " + error.GetType().Name); } detailsText.AppendLine(Logger.LogText); Debug.WriteLine(detailsText.ToString()); m_details.Text = detailsText.ToString(); if (m_fUserReport) { // show modeless, so they can use the program while filling in details. // Don't set the Ignore flag, a real crash might happen while trying to report a lesser problem. Show(parent); return; } if (s_isOkToInteractWithUser) { s_fIgnoreReport = true; ShowDialog((parent != null && !parent.IsDisposed) ? parent : null); s_fIgnoreReport = false; } else //the test environment already prohibits dialogs but will save the contents of assertions in some log. { Debug.Fail(m_details.Text); } }