Trapping errors in ASP

Discussion in 'ASP General' started by Eitan, Jan 12, 2005.

  1. Eitan

    Eitan Guest

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

    Thanks :)
    Eitan, Jan 12, 2005
    #1
    1. Advertising

  2. Eitan

    Don Grover Guest

    "Eitan" <no_spam_please@nospam_please.com> wrote in message
    news:%23LkzqyG%...
    > 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
    %>
    Don Grover, Jan 12, 2005
    #2
    1. Advertising

  3. Eitan

    Eitan Guest

    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 :)
    Eitan, Jan 12, 2005
    #3
  4. Eitan

    Jeff Cochran Guest

    On Wed, 12 Jan 2005 12:10:58 +0200, "Eitan"
    <no_spam_please@nospam_please.com> wrote:

    >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
    Jeff Cochran, Jan 12, 2005
    #4
  5. Eitan wrote:
    > 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.
    Dave Anderson, Jan 12, 2005
    #5
  6. Eitan

    Eitan Guest


    > >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. :)
    >


    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 :)
    Eitan, Jan 13, 2005
    #6
  7. Eitan wrote:
    >>> 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. :)
    >>

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

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Jan 13, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmlsbA==?=

    Trapping 'compile' errors when aspx page is rendered.

    =?Utf-8?B?QmlsbA==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    510
    =?Utf-8?B?QmlsbA==?=
    Mar 29, 2005
  2. Aaron Fude

    Trapping JNI errors

    Aaron Fude, Jun 1, 2004, in forum: Java
    Replies:
    4
    Views:
    1,494
    Gordon Beaton
    Jun 2, 2004
  3. Avi Kak
    Replies:
    6
    Views:
    315
    Duncan Booth
    Feb 13, 2006
  4. Eitan
    Replies:
    3
    Views:
    131
    Bob Barrows [MVP]
    Jan 12, 2005
  5. Gerard A.W. Vreeswijk

    trapping compile time errors

    Gerard A.W. Vreeswijk, Jul 7, 2003, in forum: Ruby
    Replies:
    5
    Views:
    134
    Robert Klemme
    Jul 7, 2003
Loading...

Share This Page