/// <summary> /// Log an exception into the system log. /// </summary> /// <param name="exception">Exception to be logged</param> /// <param name="additional"></param> public static void Log(Exception exception, string additional) { try { string name = exception.GetType().FullName; string message = exception.Message; Exception t = exception; int i = 0; while (t.InnerException != null) { t = t.InnerException; name += " : " + t.GetType().FullName; // message = t.Message; // NKIDD - ADDED message += "\r\n\r\nInnerException #" + i + ":\r\nMessage: " + t.Message + "\r\nSource: " + t.Source + "\r\nStackTrace: " + t.StackTrace; i++; } name += "\r\n\r\n Additional Info: " + additional + "\r\n" + message; if (Enabled) { if (log != null) { try { log.WriteEntry(exception.Source + " threw exception: " + exception, EventLogEntryType.Error); } catch (Exception ex) { var k = ex.Message; } } if (OnEvent != null) { OnEvent(EventLogEntryType.Error, exception.Source, exception.StackTrace, name); } } if (g_onExceptionShowMessage) { ExceptionForm ef = new ExceptionForm(exception); if (ef.ShowDialog() == DialogResult.OK) { Debugger.Break(); } ef.Dispose(); } } catch (Exception ex) { var k = ex.Message; } }
/// <summary> /// Log an exception into the system log. /// </summary> /// <param name="exception">Exception to be logged</param> public static void Log(Exception exception, string additional) { try { string name = exception.GetType().FullName; string message = exception.Message; Exception t = exception; int i = 0; while (t.InnerException != null) { t = t.InnerException; name += " : " + t.GetType().FullName; // message = t.Message; // NKIDD - ADDED message += "\r\n\r\nInnerException #" + i.ToString() + ":\r\nMessage: " + t.Message + "\r\nSource: " + t.Source + "\r\nStackTrace: " + t.StackTrace; i++; } name += "\r\n\r\n Additional Info: " + additional + "\r\n" + message; if (Enabled) { if (log != null) { try { log.WriteEntry(exception.Source + " threw exception: " + exception.ToString(), EventLogEntryType.Error); } catch (Exception) { } } if (OnEvent != null) OnEvent(EventLogEntryType.Error, exception.Source, exception.StackTrace, name); } if (g_onExceptionShowMessage == true) { ExceptionForm ef = new ExceptionForm(exception); if (ef.ShowDialog() == System.Windows.Forms.DialogResult.OK) { System.Diagnostics.Debugger.Break(); } ef.Dispose(); } } catch (Exception) { } }