24 |
public frmAdmin() |
public frmAdmin() |
25 |
{ |
{ |
26 |
InitializeComponent(); |
InitializeComponent(); |
27 |
|
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); |
28 |
} |
} |
29 |
|
|
30 |
|
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) |
31 |
|
{ |
32 |
|
Exception ex = (e.ExceptionObject as Exception); |
33 |
|
if (ex == null) |
34 |
|
{ |
35 |
|
Logging.ATSAdminLog.Error("Encountered unhandled Exception, but the exception was null"); |
36 |
|
return; |
37 |
|
} |
38 |
|
if (ex.GetType() == typeof(SqlException)) |
39 |
|
{ |
40 |
|
SqlException sql_ex = (ex as SqlException); |
41 |
|
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()))) |
42 |
|
{ |
43 |
|
Logging.ATSAdminLog.Error("Encountered unhandled SqlException"); |
44 |
|
} |
45 |
|
} |
46 |
|
else |
47 |
|
{ |
48 |
|
using (log4net.NDC.Push(string.Format("Exception: MESSAGE={0}{1}Diagnostics:{1}{2}", ex.Message, System.Environment.NewLine, ex.ToString()))) |
49 |
|
{ |
50 |
|
Logging.ATSAdminLog.Error("Encountered unhandled Exception"); |
51 |
|
} |
52 |
|
} |
53 |
|
} |
54 |
|
|
55 |
private void frmAdmin_Load(object sender, EventArgs e) |
private void frmAdmin_Load(object sender, EventArgs e) |
56 |
{ |
{ |