I am working with old ASP code and I am not sure about semantics of on error goto 0
and error resume next
construction.
Can you recommend me some useful resources or enlight me directly?
On error resume next: If there is an exception in the program, just ignore it and continue to the next statement. Considered very bad and ugly, and rightly so in my opinion. It's like having a big:
try
{
// your code
}
catch
{
// nothing! muhaha
}
in every method of your code (or worse, around the whole program).
On error goto 0: disables any error handler that is defined in the current procedure. It's like having a big try-catch around your code, which gets disabled as soon as its hit this line.
For more information, see the MSDN.
on error resume next
means just that ignore the error and resume next
on error goto 0
means to end the on error resume next
you can also do this
<%
on error resume next '<-- This code will resume and continue executing the code if there is an error
'YOUR CODE HERE
if err.number > 0 then '<-- This code will look if there are any errors (even if resumed)
' or use If Err.Number <> 0 Then
'DO SOMETHING IF ERROR
%>
Error Number <%= Err.Number %><BR>
Error Description <%= Err.Description %><BR>
Source <%= Err.Source %><BR>
LineNumber <%= Err.Line %><BR>
<%end if%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With