Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error handling in VBScript.

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
I need to know how to detect and correct errors in asp.
I have done this in Visual Basic using OnError syntax, I was wondering how error handling is achieved in VBScript. [sig][/sig]
 
Basically the same way...

at the top of the .asp page -
Code:
<% On Error Resume Next %>

after any problematic area -
Code:
If Err.number <> 0 then
 TrapError Err.description 'points to sub within include
End If

at the bottom of the page -
Code:
EvalErrors 'points to sub within include

have an include to the following -
Code:
<%
Dim strErrorMessage
Dim binErrors

'Init vars
strErrorMessage = &quot;-Error-&quot; 'or whatever
binErrors = False

Sub TrapError(strError)
 binErrors = True 'there was an error detected.
 strErrorMessage = strErrorMessage & strError
End Sub

sub EvalErrors()
 if binErrors then
  'send an e-mail 
  'display an error message (strErrorMessage)
  'whatever else
 end if
end sub 
%>

Hope this helps,
Rob
[sig][/sig]
 
Thanks Again Rob,
This is becoming a habit, I've got what I wanted to work now. Keep up the good work, thanks again. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top