Hi.... I need to trap errors in my ASP code. I understand that there are 2 types of errors in ASP. Database errors and Page errors, so i have written some code to trap both and print them to the screen.
Code:
'Error Handler
If Err.Number <> 0 Then
'Clear response buffer
Response.Clear
If IsObject(conn) Then
If conn.Errors.Count > 0 Then %>
<B>Database Connection Object</B>
<% For intLoop = 0 To conn.Errors.Count - 1 %>
Error No: <%= conn.Errors(intLoop).Number %><BR>
Description: <%= conn.Errors(intLoop).Description %><BR>
Source: <%= conn.Errors(intLoop).Source %><BR>
SQLState: <%= conn.Errors(intLoop).SQLState %><BR>
count : <%= conn.Errors.Count %><br>
NativeError: <%= conn.Errors(intLoop).NativeError %><P>
<% Next
End If
End If
If Err.Number <> 0 Then %>
<B>Page Error Object</B><BR>
Error Number <%= Err.Number %><BR>
Error Description <%= Err.Description %><BR>
Source <%= Err.Source %><BR>
LineNumber <%= Err.Line %><P>
<% End If
End If
[code]
Does anyone know where I might get something more efficient or maybe help me improve mine as its not the greatest!
It reports some errors and some dont get caught e.t.c.
thanks