How do I catch unhandled exceptions

A

Alan Silver

Hello,

One of my web sites seems to throw the occasional exception in a place
where I don't expect it. I know I should expect them anywhere, but just
supposing I've missed one, is there a way of having some sort of global
catch-all that will allow me to log the error and present the user with
some friendly message?

TIA
 
T

tdavisjr

The Global.asax has an event called Applictions.OnError, you retreive
the last exception by using Server.GetLastError and log that exception
in this event.
 
A

Alan Silver

The Global.asax has an event called Applictions.OnError, you retreive
the last exception by using Server.GetLastError and log that exception
in this event.

Thanks very much.
 
A

Alan Silver

The Global.asax has an event called Applictions.OnError, you retreive
the last exception by using Server.GetLastError and log that exception
in this event.

OK, I looked into this a bit more, and it seems I can't really get much
interesting information, such as what page generated the error and what
it was doing. The stack trace is very generic and doesn't really help me
at all.

Is there any way to get more info in this event? Even knowing which page
was being executed would be a start, but ideally I would like more than
that. TIA
 
T

tdavisjr

Oh. On the Exception object look at the InnerException and print the
stack trace for that. It will give detailed information. I forgot to
mention this.
 
A

Alan Silver

Oh. On the Exception object look at the InnerException and print the
stack trace for that. It will give detailed information. I forgot to
mention this.

Thanks, I'll see if that is any more enlightening ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top