R
Richard Coltrane
Hi there,
Ive just implemented some application level exception handling in ASP.Net
2.0. I deliberately set up a null reference error in my code to see how this
would be handled.
Sure enough the applicationOnError code runs in Global.asax and hands it off
to my custom error page but theres no info in the exception returned by
Server.Getlasterror.
The type of this exception is just HttpUnhandledException (which is obvious,
thats why Im catching it at the global level). I was under the impression i
would get a reference to the original NullRefException via GetBaseException
but this is empty? This from my immediate window:
?Server.GetLastError
{"Exception of type 'System.Web.HttpUnhandledException' was thrown."}
System.Web.HttpUnhandledException: {"Exception of type
'System.Web.HttpUnhandledException' was thrown."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: Nothing
InnerException: {"Object reference not set to an instance of an object."}
Message: "Exception of type 'System.Web.HttpUnhandledException' was thrown."
Source: "System.Web"
StackTrace: " at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)"
TargetSite: {System.Reflection.RuntimeMethodInfo}
So now i have a catch all last resort and redirect in the case of a bug in
my code. Thats more tidy for the user...but what am i supposed to use for
diagnostic info?
I thought this was the major reason for
Server.GetLastError.GetBaseException? All its telling me is what i can infer
simply from the fact that this code runs...i.e an unhandled error has
occured.
Thanks
Richard
Ive just implemented some application level exception handling in ASP.Net
2.0. I deliberately set up a null reference error in my code to see how this
would be handled.
Sure enough the applicationOnError code runs in Global.asax and hands it off
to my custom error page but theres no info in the exception returned by
Server.Getlasterror.
The type of this exception is just HttpUnhandledException (which is obvious,
thats why Im catching it at the global level). I was under the impression i
would get a reference to the original NullRefException via GetBaseException
but this is empty? This from my immediate window:
?Server.GetLastError
{"Exception of type 'System.Web.HttpUnhandledException' was thrown."}
System.Web.HttpUnhandledException: {"Exception of type
'System.Web.HttpUnhandledException' was thrown."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: Nothing
InnerException: {"Object reference not set to an instance of an object."}
Message: "Exception of type 'System.Web.HttpUnhandledException' was thrown."
Source: "System.Web"
StackTrace: " at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.pages_crmad_aspx.ProcessRequest(HttpContext context)
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)"
TargetSite: {System.Reflection.RuntimeMethodInfo}
So now i have a catch all last resort and redirect in the case of a bug in
my code. Thats more tidy for the user...but what am i supposed to use for
diagnostic info?
I thought this was the major reason for
Server.GetLastError.GetBaseException? All its telling me is what i can infer
simply from the fact that this code runs...i.e an unhandled error has
occured.
Thanks
Richard