Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP will still execute code after run-time error has detected?

Reply
Thread Tools

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

 
 
John
Guest
Posts: n/a
 
      07-13-2006
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>"
%>

////////////////////////////////////////////

 
Reply With Quote
 
 
 
 
Mike Brind
Guest
Posts: n/a
 
      07-13-2006

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.net - Execute code after reurn statement? marktm@gmail.com ASP .Net 2 05-16-2006 07:47 PM
VB.net - Execute code after reurn statement? marktm@gmail.com ASP .Net 0 05-16-2006 06:26 PM
Execute code after death of all child processes - (corrected posting) Markus Franz Python 2 12-28-2004 03:35 PM
Execute code after death of all child processes Markus Franz Python 2 12-24-2004 06:11 PM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM



Advertisments