Geting Source Code from Exception.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary van der Merwe

    #1

    Geting Source Code from Exception.

    I have a web application which has a custom error handler
    which displays frendly message to user and emails me the
    details.

    The standard Asp.NET error handler page will, if the
    project is in debug mode, display the line of code that
    the error occoured on, as well as the previous and next 3
    lines.

    I would realy like to put this info in to the email that I
    send to myself.

    I think it might start with Excepition.Targ etSite.
    ..


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Geting Source Code from Exception.

    Gary,

    I think that what you want to do is use the StackTrace instance which is
    exposed by the exception thrown. You can then call ToString to get the code
    that caused the error, I believe.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nick(dot)paldin o=at=exisconsul ting<dot>com

    "Gary van der Merwe" <garyvdm@hotmai l.com> wrote in message
    news:0daa01c388 f0$959da110$a00 1280a@phx.gbl.. .[color=blue]
    > I have a web application which has a custom error handler
    > which displays frendly message to user and emails me the
    > details.
    >
    > The standard Asp.NET error handler page will, if the
    > project is in debug mode, display the line of code that
    > the error occoured on, as well as the previous and next 3
    > lines.
    >
    > I would realy like to put this info in to the email that I
    > send to myself.
    >
    > I think it might start with Excepition.Targ etSite.
    > .
    >
    >[/color]


    Comment

    • Gary van der Merwe

      #3
      Re: Geting Source Code from Exception.

      Ha I figered out how they (std ASP.Net Error Page) do it -
      not what I was hopeing though.

      They read the code from the file. They get the file name
      and line number from the stack trace. If file name of the
      first Stack Frame is not availible, it looks for the
      second, ect..

      I concluded this by renaming the file that the exception
      was been thrown in. It then showed the code for the class
      that the method was called by.

      I was realy hoping that the code was stored in the PDB
      file, and that I could access it somehow.

      Gary.
      [color=blue]
      >-----Original Message-----
      >Gary,
      >
      > I think that what you want to do is use the[/color]
      StackTrace instance which is[color=blue]
      >exposed by the exception thrown. You can then call[/color]
      ToString to get the code[color=blue]
      >that caused the error, I believe.
      >
      > Hope this helps.
      >
      >
      >--
      > - Nicholas Paldino [.NET/C# MVP]
      > - nick(dot)[/color]
      paldino=at=exis consulting<dot> com[color=blue]
      >
      >"Gary van der Merwe" <garyvdm@hotmai l.com> wrote in[/color]
      message[color=blue]
      >news:0daa01c38 8f0$959da110$a0 01280a@phx.gbl. ..[color=green]
      >> I have a web application which has a custom error[/color][/color]
      handler[color=blue][color=green]
      >> which displays frendly message to user and emails me the
      >> details.
      >>
      >> The standard Asp.NET error handler page will, if the
      >> project is in debug mode, display the line of code that
      >> the error occoured on, as well as the previous and next[/color][/color]
      3[color=blue][color=green]
      >> lines.
      >>
      >> I would realy like to put this info in to the email[/color][/color]
      that I[color=blue][color=green]
      >> send to myself.
      >>
      >> I think it might start with Excepition.Targ etSite.
      >> .
      >>
      >>[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...