Trapping errors in ASP

D

Don Grover

Eitan said:
Hello,
I need an example of "Trapping Errors" in ASP (not .net)

Thanks :)


<%
'test.asp
'Error Trap
On Error Resume Next
Response.Write 0/0
If Err.Number <> 0 Then
Response.Write Err.Description
Else
Response.Write "No Error Found"
End If

Response.End
%>
 
E

Eitan

Can I trap on specific label, and not after the error occured.
(I know : on error goto my_label ...
but this does not work in ASP pages)
Thanks :)
 
J

Jeff Cochran

Can I trap on specific label, and not after the error occured.
(I know : on error goto my_label ...
but this does not work in ASP pages)

Actually, you can never trap on an error that doesn't occur. :)

Use the same setup, and either handle the error instead of
Response.Write'ing it out, or call a function to handle the error and
return whatever you need to continue processing. You can even handle
errors based on the error number.

I used to have a link to a document on either ASPFaq or 4GuysFromRolla
about error trapping, but it's not in my links (or I saved the link on
another system...). A search on both doesn't really turn up what I
remmbered, but there's info out there.

Jeff
 
D

Dave Anderson

Eitan said:
Can I trap on specific label, and not after the error occured.
(I know : on error goto my_label ...

No.
http://msdn.microsoft.com/library/en-us/script56/html/vsstmonerror.asp



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
E

Eitan

Actually, you can never trap on an error that doesn't occur. :)

You didnt understand me.
I meant that : the error occurred, but I don't want just after line that
cause the error, but to goto a specific label.
(on "error goto my_label" doesn't work on asp, but only on VB, and "on error
resume next" is not what I am searching for).

'Thanks :)
 
B

Bob Barrows [MVP]

Eitan said:
You didnt understand me.
I meant that : the error occurred, but I don't want just after line
that cause the error, but to goto a specific label.
(on "error goto my_label" doesn't work on asp,

correction: not "asp", asp is not a language. It is a platform supporting
multiple scripting languages, including vbscript (which is what I'm sure you
meant to say instead of "asp", right?), jscript, etc.
but only on VB, and
"on error resume next" is not what I am searching for).

'Thanks :)

Sorry, but that's the only game in town when using vbscript. As somebody
else said, you can switch to using jscript in your server-side code,
allowing you to use try...catch...finally.

Bob Barrows
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top