468,117 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

script for on error goto errhandler

is't asp supported for on error goto error handler?
if so can anybody give me some hint for it...
i need to make my page get to other link if detecting an error
Nov 5 '08 #1
3 10590
DrBunchman
979 Expert 512MB
Hi MATTXtwo,

The first thing to do is to put the following line at the top of your page:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. On Error Resume Next
  3. %>
This tells the interpreter to ignore any errors and carry on processing the script. The next thing you need is a bit of code to trap any errors which occur:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. If Not Err.Number = 0 Then
  3. Response.Write Err.Description
  4. Error.Clear
  5. End If
  6. %>
You can put whatever you like in this second bit of code to handle the error as required.

Hope this helps and let me know how you get on,

Dr B
Nov 5 '08 #2
Expand|Select|Wrap|Line Numbers
  1. <%
  2. On Error Resume Next
  3. %>
Expand|Select|Wrap|Line Numbers
  1. <%
  2. If Not Err.Number = 0 Then
  3. Response.Write Err.Description
  4. Error.Clear
  5. End If
  6. %>
Thanks DrB ...
Can I do like this..
ON ERROR code top of page
iif statement bottom of page?
and can this code catch all error on pages?
Nov 5 '08 #3
DrBunchman
979 Expert 512MB
Yes, that's how it should work.

Give it a go and let me know what happens. You should be able to force your page to error quite easily so you can test it.

Dr B
Nov 5 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Geoff Turner | last post: by
11 posts views Thread by ColdCanuck | last post: by
2 posts views Thread by christianlott1 | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.