Error Handling

J

John .

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?
 
R

Ray Costanzo [MVP]

How about something like this:

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

Ray at work
 
R

Ray Costanzo [MVP]

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
 
J

John .

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?
 
M

McKirahan

Ray Costanzo said:
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 . said:
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.
 
J

John .

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?
 
J

John .

...
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.
 

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

Similar Threads

Procedure Invalid Identifier in SQL / PLSQL 1
PHP error 1
ASP errors 1
err.raise 1
Axios 403 error when sending get request 3
Exception Handling 33
Error Handling 27
Argparse error using NodeJS 0

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top