///TODO: Change the invoke params to support normal Exception public static void ReportException(object sender, ThreadExceptionEventArgs e) { //mission critical exception, show console to user for reporting SessionManager.SMptr.Opacity = 100; SessionManager.SMptr.Show(); EC ecn = new EC { EDesc = "APPLICATION EXCEPTION - " + e.GetType().Name, ETime = DateTime.Now, EType = "Fatal" }; EDict.Add(ecn); ReportEx("APPLICATION CRITICAL EXCEPTION DIFFUSED", RType.ERROR, Color.Red, false, false, false, true); ReportEx("EX-> " + e.Exception.Message, RType.ERROR, RTC[3], false, false, false, true); ReportEx(e.Exception.StackTrace, RType.ERROR, RTC[3], false, false, false, true); SessionManager.SMptr.ErrorDisplay.Text = EDict.Count + " Errors"; }
public static void ReportEx(string InboundText, RType ReportType = (RType)2, Color BaseColor = new Color(), bool Time = true, bool Tag = true, bool Append = false, bool IgnoreError = false) { //initialize RichTextBox stdout = SessionManager.SMptr.Log; DateTime reporttime = DateTime.Now; if (ReportType == RType.ERROR && IgnoreError == false) { EC ecn = new EC { EDesc = InboundText, ETime = reporttime, EType = "Error" }; EDict.Add(ecn); SessionManager.SMptr.ErrorDisplay.Text = EDict.Count + " Errors"; } stdout.SuspendLayout(); //begin print if (Append == false) { stdout.AppendText(Environment.NewLine); } //PRINT TIME if (Time) { stdout.SelectionColor = RTC[1]; stdout.AppendText("[" + reporttime.ToString("H:mm:ss") + "] "); } //PRINT REPORT TYPE if (Tag) { stdout.SelectionColor = (int)ReportType == -1 ? Color.Purple : RTC[Math.Abs((int)ReportType)]; stdout.AppendText("[" + ReportType.ToString() + "] "); } stdout.SelectionColor = (BaseColor.IsEmpty) ? RTC[1] : BaseColor; stdout.AppendText(InboundText); stdout.ScrollToCaret(); stdout.ResumeLayout(); Console.WriteLine(InboundText); }