// (generated using a center with a padding of 40 chars and a dash sep. `.center(40, '-')` // Thanks Python2, da real MVP <3) public static void HandleOleDBError(OleDbException e) { FatalErrorReporter errorReporter; StringBuilder collectedErrorData = new StringBuilder(); // ole db exception // error collection sample collectedErrorData.AppendLine("------- A DB EXCEPTION OCCURRED --------"); for (int i = 0; i <= e.Errors.Count - 1; i++) { collectedErrorData.AppendLine( string.Format("----------------- {0:000} ------------------", i) ); collectedErrorData.AppendLine("Message: " + e.Errors[i].Message); collectedErrorData.AppendLine("Native: " + e.Errors[i].NativeError.ToString()); collectedErrorData.AppendLine("Source: " + e.Errors[i].Source); collectedErrorData.AppendLine("SQL: " + e.Errors[i].SQLState); } collectedErrorData.AppendLine("---------------- STACK -----------------"); collectedErrorData.AppendLine(e.StackTrace); collectedErrorData.AppendLine("----------------- END ------------------"); Console.WriteLine(collectedErrorData); errorReporter = new FatalErrorReporter(collectedErrorData.ToString()); errorReporter.ShowDialog(); }
public static void HandleBaseException(Exception e) { FatalErrorReporter errorReporter; StringBuilder collectedErrorData = new StringBuilder(); // error collection sample collectedErrorData.AppendLine("-------- AN EXCEPTION OCCURRED ---------"); collectedErrorData.AppendLine("Type: " + e.GetType().ToString()); collectedErrorData.AppendLine("Message: " + e.Message); collectedErrorData.AppendLine("Source: " + e.Source); collectedErrorData.AppendLine("---------------- STACK -----------------"); collectedErrorData.AppendLine(e.StackTrace); collectedErrorData.AppendLine("----------------- END ------------------"); Console.WriteLine(collectedErrorData); errorReporter = new FatalErrorReporter(collectedErrorData.ToString()); errorReporter.ShowDialog(); }