Exceptions

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

Hello,

I am writing a custom error page for my web application
and I need to inform the user of the line number and the
page name where an error occurs (like it does in the
standard ASP.NET error page) but the exception class does
not contain these details, does anyone know how I can get
these?

Many thanks

Robert
 
Try creating an instance of the StackTrace class. I believe on of the
constructors takes an exception object. You can then go up or down the
stack, getting the line number at each level (if available).
 
Robert,

I created an object that emails exceptions from all of our apps whenever
they occurr.

If you'd like to look at some of it's code the entire project is
downloadable from my web site, www.aboutfortunate.com. Just click the code
library link on the top right of the page and then click the errorhandling
button in the left menu.

Everything on my web site is free.

Something to keep in mind: When an application is set to debug mode the
exceptions thrown include line numbers but when an application is compiled
in release mode the exceptions thrown will not include line numbers. This is
because not all lines of code translate into the same line numbers when an
app is compiled. For example no comments are included in compiled code.
Also, since the app is being compiled twice, once to Microsoft Intermediate
Language and a second time when it's Jit'd then line numbers in the release
version will never match up since the language is different.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com


"Out of chaos comes order."
Nietzche
 
Back
Top