Error Handling

Discussion in 'ASP General' started by John ., Oct 28, 2005.

  1. John .

    John . Guest

    I have an error handling routine that emails me the Err.Source, Err.Nbr,
    and Err.Description in the event of an error. How can I include the
    line number of the error as well and the filename?



    *** Sent via Developersdex http://www.developersdex.com ***
    John ., Oct 28, 2005
    #1
    1. Advertising

  2. How about something like this:

    ??????????????????????????????????????????????????????>?????????????????????????????????????>????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????>????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????>?????????????????????..??????????????????.???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????>?????????????????????....????????????

    Ray at work

    "John ." <> wrote in message
    news:eYLYeK%...
    >I have an error handling routine that emails me the Err.Source, Err.Nbr,
    > and Err.Description in the event of an error. How can I include the
    > line number of the error as well and the filename?
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Ray Costanzo [MVP], Oct 28, 2005
    #2
    1. Advertising

  3. Or try this understable reply. :| This particular code is meant for
    displaying error data in a custom error page, but it'll give you info on
    getting error information.


    Dim aErrorInfo(1,13)
    Dim oError
    Set oError = Server.GetLastError

    aErrorInfo(0,0) = "ASP Code" : aErrorInfo(1,0) = oError.ASPCode
    aErrorInfo(0,1) = "ASP Description" : aErrorInfo(1,1) =
    oError.ASPDescription
    aErrorInfo(0,2) = "Description" : aErrorInfo(1,2) = oError.Description
    aErrorInfo(0,3) = "Category" : aErrorInfo(1,3) = oError.Category
    aErrorInfo(0,4) = "Number" : aErrorInfo(1,4) = oError.Number
    aErrorInfo(0,5) = "Source" : aErrorInfo(1,5) = oError.Source
    aErrorInfo(0,6) = "File" : aErrorInfo(1,6) = oError.File
    aErrorInfo(0,7) = "Line" : aErrorInfo(1,7) = oError.Line
    aErrorInfo(0,8) = "Querystring" : aErrorInfo(1,8) = Request.Querystring
    On Error Resume Next
    aErrorInfo(0,9) = "Form Data" : aErrorInfo(1,9) = Request.Form
    If Err.Number <> 0 Then aErrorInfo(0,9) = "(binary data)"
    On Error Goto 0
    aErrorInfo(0,10) = "All HTTP" : aErrorInfo(1,10) = "<textarea
    style=""width: 410px; height=100px; font: 8pt verdana;"">" &
    Request.ServerVariables("ALL_HTTP") & "</textarea>"
    aErrorInfo(0,11) = "Remote Address" : aErrorInfo(1,11) =
    Request.ServerVariables("REMOTE_ADDR")
    aErrorInfo(0,12) = "Description" : aErrorInfo(1,12) =
    Request.ServerVariables("REMOTE_HOST")
    aErrorInfo(0,13) = "Request Date" : aErrorInfo(1,13) = FormatDateTime(Now,
    1) & " " & FormatDateTime(Now, 3)

    Ray at work


    "John ." <> wrote in message
    news:eYLYeK%...
    >I have an error handling routine that emails me the Err.Source, Err.Nbr,
    > and Err.Description in the event of an error. How can I include the
    > line number of the error as well and the filename?
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Ray Costanzo [MVP], Oct 28, 2005
    #3
  4. John .

    John . Guest

    John ., Oct 28, 2005
    #4
  5. No problem Jonn.

    Ray at work

    "John ." <> wrote in message
    news:ule5lV%...
    > thanks costanza. i'll try that. i'm sure that will do the trick.
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Ray Costanzo [MVP], Oct 28, 2005
    #5
  6. John .

    John . Guest

    does this work for error codes below 100? i.e. type mismatches (13).

    also, can the object be used as a parameter in a subroutine?


    *** Sent via Developersdex http://www.developersdex.com ***
    John ., Oct 28, 2005
    #6
  7. John .

    McKirahan Guest

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:OHWKkR#...
    > Or try this understable reply. :| This particular code is meant for
    > displaying error data in a custom error page, but it'll give you info on
    > getting error information.


    [snip]

    > "John ." <> wrote in message
    > news:eYLYeK%...
    > >I have an error handling routine that emails me the Err.Source, Err.Nbr,
    > > and Err.Description in the event of an error. How can I include the
    > > line number of the error as well and the filename?


    http://www.devguru.com/Technologies/asp/quickref/server_getlasterror.html

    "By default, the error information is sent to the
    "\iishelp\common\500-100.asp" file."

    Also, "Category" is another one.
    McKirahan, Oct 28, 2005
    #7
  8. Give it a try and see! http://www.aspfaq.com/5007

    Ray at work

    "John ." <> wrote in message
    news:%23ns5eI$...
    >
    > does this work for error codes below 100? i.e. type mismatches (13).
    >
    > also, can the object be used as a parameter in a subroutine?
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Ray Costanzo [MVP], Oct 28, 2005
    #8
  9. John .

    John . Guest

    I did and it didn't seem to do anything. I tried without passing as an
    object and it didn't return any info about the error. Is the
    GetLastError available in IIS 6.0 too?



    *** Sent via Developersdex http://www.developersdex.com ***
    John ., Oct 29, 2005
    #9
  10. Ray Costanzo [MVP], Oct 31, 2005
    #10
  11. John .

    John . Guest

    ...
    If (Err.number <> 0 ) Then
    Set objASPError = Server.GetLastError()
    Response.Write "Error Description: " & objASPError.Description
    End If
    ...

    When the error occurs "Error Description: " is the only thing written to
    the screen.




    *** Sent via Developersdex http://www.developersdex.com ***
    John ., Nov 2, 2005
    #11
    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. Kenneth Keeley

    Error Handling

    Kenneth Keeley, Jul 1, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    372
    Kenneth Keeley
    Jul 1, 2003
  2. VSK
    Replies:
    1
    Views:
    767
    Alvin Bruney
    Jul 29, 2003
  3. Mark Tarver
    Replies:
    22
    Views:
    1,280
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,916
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    175
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page