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 Wanet Telecoms Ltd 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 ASP

Status
Not open for further replies.

Johnnie100

Programmer
Dec 8, 2000
31
GB
I've got a class in ASP and instantiate an object with it. Within the class is no error handling as yet. I understand that VBScript error handling is similar to that in VB - I have tried using the same sort of error handling but am getting a syntax error.

Any help would be gratefully appreciated. The code is;

Public Function GetURL(ByRef pStrURL)
'Variables
Dim lObjSpider
Dim strText

'Return if no URL has been passed
If pStrURL = "" Then Exit Function

'On Error Resume Next

'Create spider object
Set lObjSpider = Server.CreateObject ("Microsoft.XMLHTTP")


' Could not create Internet Control
If Err Then
GetURL = "Error: " & Err.Description
Exit Function
End If

'On Error Goto 0
On Error Goto Error_Handler

With lObjSpider
.Open "GET", pStrURL, False, "", ""
.Send
GetURL = .ResponseText
End With
Set LobjSpider = Nothing

'strHTML = GetURL
RetrievedstrHTML = "Andy tester text"
'Return
Exit Function

'Error handling
Error_Handler:
GetURL=""
End Function
 
uncomment "On Error Resume Next" then use

if err <> 0 then
<< handler >>
exit function or whatever
end if My daily story these days:
9am [pc2] => 3p [flush] => 6p [pc2] => 10p [yawn2] 12a [hammer] => 1a [pc1] 3a [sleeping] => fri [cheers]
 
You have mixed two types of error handling in your statement. You should use either the method bgaines has listed (that you have partially already) or use the Error_Handler tag you have created by doing an On Error Goto Error_Handler. Either method should work exactly like you are used to in VB.

-Tarwn ________________________________________________
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top