4

I have a .NET 4.0 web application which implements an error handler within the Application_Error event of Global.asax.

When an exception occurs this intercepts it and sends me an email including a variety of information like the logged in user, the page the error occurred on, the contents of the session etc.

This is all great but there is some fundamental detail missing which I seem unable to locate.

For instance, this is a subset of an error I would receive and the associated stack trace:

Source: Telerik.Web.UI Message: Selection out of range Parameter name: value Stack trace: at Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource) at Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) at Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e) at Telerik.Web.UI.RadComboBox.PerformSelect() at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at Telerik.Web.UI.RadComboBox.DataBind() at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() at Telerik.Web.UI.RadComboBox.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

Now as lovely as this is I could do with knowing a) the name of the control and b) the value which caused the control to be 'out of range'.

Any suggestions about how I could get this sort of information? I've run this in debug mode and the objects passed to Global.asax don't seem to hold any more detail that I can see.

7
  • You'll need to catch the exception where it occurs and log it from there to get the information you're looking for. Commented Mar 19, 2012 at 17:59
  • Have you tried to override MasterPage.OnError(EventArge)? Commented Mar 19, 2012 at 18:00
  • How are you getting the data you are already showing? Is it that the exception doesn't contain the info you want? If so you may be out of luck unless you are in a position to add more data to the thrown exception... Commented Mar 19, 2012 at 18:01
  • Thanks Brian but with an application with 1000's of controls it is a little impractical to have individual handlers for every control Commented Mar 19, 2012 at 18:01
  • @cusimar9: Do you have master page? Try to handle into it. Commented Mar 19, 2012 at 18:03

3 Answers 3

2

Ship your PDBs along with your assemblies. This way you will get line numbers and source code filenames in your exception stack trace. And once you have line numbers you know what code you have written on that line.

Sign up to request clarification or add additional context in comments.

3 Comments

The error I posted above was with all debug options turned on and running within the IDE
@cusimar9, the error you have shown is inside some Telerik assembly. Do you have the PDBs for it as well? In this stack trace we can't actually see where the exception originates in your code.
No I don't have the PDB for the Telerik assembly, that is a third party toolkit. I'm not interested in WHERE within the Telerik assembly the exception occurs, I need to kwow which control on my page is causing it. I do have the PDBs for the projects within my solution
0

I was unable to fulfil my requirement without implementing some custom code.

I have now added some code within the MasterPage that stores __EVENTTARGET and __EVENTARGUMENT parameters upon every postback. These are cleared whenever there is a fresh page load. If an error occurs, these values form part of the debug email which allow us to get an understanding of what the user was doing when the error occurred.

Comments

-1

You can show such exception as follows

try { } catch(Exception ex) { Response.Write("Source: " + ex.Source); Response.Write("Message: " + ex.Message); Response.Write("Stack Trace: " + ex.StackTrace); } 

2 Comments

I already display all that information (see my post) but it doesn't show all detail of the error
Then you can also add some more information like this in Exception If an exception occurs in a Button1_Click then add like Response.Write("Exception Caused in Button1 of PageName.aspx

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.