ASP will still execute code after run-time error has detected?

Discussion in 'ASP General' started by John, Jul 13, 2006.

  1. John

    John Guest

    The following code has run-time error on "divide by 0" error. I expect
    "do the work<br>" will not print in the browser, since it happen after
    the code
    that cause the error. However, this is the output: any ideas why?? Or
    this is the nature of ASP scripting language that is being executed in
    sequential order? Please advice. thanks!!

    //////// output ///////////////////////////

    before error
    do the work
    Division by zero
    after error handling

    /////////// code ///////////////////////////
    <%
    On Error Resume Next
    Response.write "before error<br>"
    dblValue = 1/aa '== Will cause a divide by 0 error

    Response.Write "do the work<br>"

    If Err.Number <> 0 Then
    Response.write Err.Description & "<br>"
    End If

    Response.Write "after error handling<br>"
    %>

    ////////////////////////////////////////////
     
    John, Jul 13, 2006
    #1
    1. Advertising

  2. John

    Mike Brind Guest

    John wrote:
    > The following code has run-time error on "divide by 0" error. I expect
    > "do the work<br>" will not print in the browser, since it happen after
    > the code
    > that cause the error. However, this is the output: any ideas why?? Or
    > this is the nature of ASP scripting language that is being executed in
    > sequential order? Please advice. thanks!!
    >
    > //////// output ///////////////////////////
    >
    > before error
    > do the work
    > Division by zero
    > after error handling
    >
    > /////////// code ///////////////////////////
    > <%
    > On Error Resume Next
    > Response.write "before error<br>"
    > dblValue = 1/aa '== Will cause a divide by 0 error
    >
    > Response.Write "do the work<br>"
    >
    > If Err.Number <> 0 Then
    > Response.write Err.Description & "<br>"
    > End If
    >
    > Response.Write "after error handling<br>"
    > %>
    >
    > ////////////////////////////////////////////


    'On Error Resume Next' tells the compiler to ignore any runtime errors
    and resume with the next line of code. Details of the (last) error are
    stored in the Err Object. Without 'On Error Resume Next', the compiler
    would halt processing this script at the point it encounters a divide
    by zero error (or indeed any runtime error).

    --
    Mike Brind
     
    Mike Brind, Jul 13, 2006
    #2
    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. Len
    Replies:
    3
    Views:
    1,471
  2. paul clayton via .NET 247
    Replies:
    2
    Views:
    11,141
    Fred Chateau
    Jun 28, 2004
  3. =?Utf-8?B?U3VtbWl0?=
    Replies:
    2
    Views:
    2,008
    =?Utf-8?B?U3VtbWl0?=
    Dec 15, 2004
  4. Replies:
    0
    Views:
    415
  5. Replies:
    1
    Views:
    398
    Lowell Heddings
    Dec 15, 2004
Loading...

Share This Page