ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/TSAdminTool/Program.cs
(Generate patch)

Comparing trunk/TSAdminTool/Program.cs (file contents):
Revision 60 by william, Thu Jul 12 16:47:17 2012 UTC vs.
Revision 61 by william, Thu Jul 12 17:34:46 2012 UTC

# Line 13 | Line 13 | namespace AnywhereTS
13          /// </summary>
14          [STAThread]
15          static void Main()
16 <        {          
16 >        {
17 >            AppDomain currentDomain = AppDomain.CurrentDomain;
18 >            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
19 >            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
20 >
21              Application.EnableVisualStyles();
22              Application.SetCompatibleTextRenderingDefault(false);
23              Application.Run(new frmAdmin());
24          }
25 +        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args)
26 +        {
27 +            Exception e = (Exception)args.ExceptionObject;
28 +            if (e == null)
29 +            {
30 +                Logging.ATSAdminLog.Error("Encountered unhandled Exception, but the exception was null");
31 +                return;
32 +            }
33 +            if (e.GetType() == typeof(SqlException))
34 +            {
35 +                SqlException sql_ex = (e as SqlException);
36 +                using (log4net.NDC.Push(string.Format("SqlException: ID={0} MESSAGE={1}{2}Diagnostics:{2}{3}", sql_ex.Number.ToString(), sql_ex.Message, System.Environment.NewLine, sql_ex.ToString())))
37 +                {
38 +                    Logging.ATSAdminLog.Error("Encountered unhandled SqlException");
39 +                }
40 +            }
41 +            else
42 +            {
43 +                using (log4net.NDC.Push(string.Format("Exception: MESSAGE={0}{1}Diagnostics:{1}{2}", e.Message, System.Environment.NewLine, e.ToString())))
44 +                {
45 +                    Logging.ATSAdminLog.Error("Encountered unhandled Exception");
46 +                }
47 +            }
48 +        }
49      }
50   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines