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

J

John

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

////////////////////////////////////////////
 
M

Mike Brind

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top