Parent Directory
|
Revision Log
|
Patch
--- trunk/TSControlPanel/Program.cs 2012/07/12 21:23:35 72 +++ trunk/TSControlPanel/Program.cs 2012/07/12 22:00:37 73 @@ -40,7 +40,7 @@ Exception e = (Exception)args.ExceptionObject; if (e == null) { - Logging.TSControlPanelLog.Error("Encountered unhandled Exception, but the exception was null"); + Logging.ATSAdminLog.Error("Encountered unhandled Exception, but the exception was null"); return; } if (e.GetType() == typeof(SqlException)) @@ -49,8 +49,33 @@ List<string> strs = new List<string>(); using (log4net.NDC.Push(string.Format("{0}: ID={1} MESSAGE={2}{3}Diagnostics:{3}{4}", sql_ex.GetType().Name, sql_ex.Number.ToString(), sql_ex.Message, System.Environment.NewLine, sql_ex.ToString()))) { - strs = Logging.GetMessagesFromThreadContextStack("NDC"); - Logging.ATSAdminLog.Error("Encountered unhandled Exception"); + Exception inner = sql_ex.InnerException; + if (inner != null) + { + + if (inner.GetType() == typeof(SqlException)) + { + SqlException sql_inner = inner as SqlException; + using (log4net.NDC.Push(string.Format("{0}: ID={1} MESSAGE={2}{3}Diagnostics:{3}{4}", sql_inner.GetType().Name, sql_inner.Number.ToString(), sql_inner.Message, System.Environment.NewLine, sql_inner.ToString()))) + { + strs = Logging.GetMessagesFromThreadContextStack("NDC"); + Logging.ATSAdminLog.Error("Encountered unhandled Exception"); + } + } + else + { + using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", inner.GetType().Name, inner.Message, System.Environment.NewLine, inner.ToString()))) + { + strs = Logging.GetMessagesFromThreadContextStack("NDC"); + Logging.ATSAdminLog.Error("Encountered unhandled Exception"); + } + } + } + else + { + strs = Logging.GetMessagesFromThreadContextStack("NDC"); + Logging.ATSAdminLog.Error("Encountered unhandled Exception"); + } } StringBuilder builder = new StringBuilder(); foreach (string str in strs) { builder.AppendLine(str); } @@ -63,8 +88,20 @@ List<string> strs = new List<string>(); using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", e.GetType().Name, e.Message, System.Environment.NewLine, e.ToString()))) { - strs = Logging.GetMessagesFromThreadContextStack("NDC"); - Logging.ATSAdminLog.Error("Encountered unhandled Exception"); + Exception inner = e.InnerException; + if (inner != null) + { + using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", inner.GetType().Name, inner.Message, System.Environment.NewLine, inner.ToString()))) + { + strs = Logging.GetMessagesFromThreadContextStack("NDC"); + Logging.ATSAdminLog.Error("Encountered unhandled Exception"); + } + } + else + { + strs = Logging.GetMessagesFromThreadContextStack("NDC"); + Logging.ATSAdminLog.Error("Encountered unhandled Exception"); + } } StringBuilder builder = new StringBuilder(); foreach (string str in strs) { builder.AppendLine(str); }
ViewVC Help | |
Powered by ViewVC 1.1.22 |