script for on error goto errhandler

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MATTXtwo
    New Member
    • Sep 2006
    • 83

    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
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi MATTXtwo,

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

    Code:
    <%
    On Error Resume Next
    %>
    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:

    Code:
    <%
    If Not Err.Number = 0 Then
    Response.Write Err.Description
    Error.Clear
    End If
    %>
    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

    Comment

    • MATTXtwo
      New Member
      • Sep 2006
      • 83

      #3
      Code:
      <%
      On Error Resume Next
      %>
      Code:
      <%
      If Not Err.Number = 0 Then
      Response.Write Err.Description
      Error.Clear
      End If
      %>
      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?

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        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

        Comment

        Working...