How do I catch unhandled exceptions

Discussion in 'ASP .Net' started by Alan Silver, Mar 20, 2006.

  1. Alan Silver

    Alan Silver Guest

    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

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
     
    Alan Silver, Mar 20, 2006
    #1
    1. Advertising

  2. Alan Silver

    tdavisjr Guest

    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.
     
    tdavisjr, Mar 20, 2006
    #2
    1. Advertising

  3. Alan Silver

    Alan Silver Guest

    In article <>,
    tdavisjr <> writes
    >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.

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
     
    Alan Silver, Mar 20, 2006
    #3
  4. Alan Silver

    Alan Silver Guest

    In article <>,
    tdavisjr <> writes
    >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

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
     
    Alan Silver, Mar 22, 2006
    #4
  5. Alan Silver

    tdavisjr Guest

    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.
     
    tdavisjr, Mar 22, 2006
    #5
  6. Alan Silver

    Alan Silver Guest

    In article <>,
    tdavisjr <> writes
    >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 ;-)

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
     
    Alan Silver, Mar 23, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. terry

    Unhandled Exceptions & Framesets

    terry, Jul 2, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    443
    Bassel Tabbara [MSFT]
    Jul 3, 2003
  2. Replies:
    1
    Views:
    412
    Darren Kopp
    Mar 7, 2006
  3. Winista

    Unhandled Exceptions thrown

    Winista, Mar 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    409
    Winista
    Mar 22, 2006
  4. Warren Tang
    Replies:
    1
    Views:
    906
    Warren Tang
    Sep 23, 2008
  5. Tomasz
    Replies:
    4
    Views:
    443
    Steven Cheng[MSFT]
    Jan 23, 2007
Loading...

Share This Page