Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "on error goto 0" and "error resume next" in old ASP mean?

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?

like image 936
Jakub Šturc Avatar asked May 13 '09 08:05

Jakub Šturc


2 Answers

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.

like image 79
Razzie Avatar answered Sep 25 '22 00:09

Razzie


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%>
like image 41
compcobalt Avatar answered Sep 22 '22 00:09

compcobalt