Re: on error resume next

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

My philosophy is to never use On Error Resume Next except on a statement I
expect could raise an error under certain conditions (like the DC is not
available, or the user supplied bad imput). I always trap the error
condition, then restore normal error handling with On Error GoTo 0.

This means that my production scripts (and programs) can show error
messages. I know some consider this unsightly, but my opinion is that I'd
rather have the user call with an error message (which usually leads me
right to the problem), than call to say it doesn't work with no clue why.
Some of my scripts are used by school children, and I'd still rather know
there is a problem, rather than pretend there isn't. This also helps me
learn from problems, and be more carefull when I code.

If you want a switch to turn error handling on and off, a global boolean
could do that. VB has more functionality, where you can use "On Error GoTo
ErrorRoutine", but this is not available in VBScript. .NET has something
even better. Even in VB I display an error message so the user can give me a
clue about the problem. Otherwise, I have to restore the error handling, and
if the problem cannot be duplicated easily, I'm stuck.

The only time I can see where you want a production script to use On Error
Resume Next is where you truely want the script to never halt. Just my
opinion, but I think the coder is lazy. A lot of damage could result, or at
least the results could be wrong or incomplete. Just my opinion.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Big D" <BigDaddy@xxxxxxxxxxxxxxxx> wrote in message
news:u4GdqszLGHA.3260@xxxxxxxxxxxxxxxxxxxxxxx
I am asking for advice when using On Error Resume Next.

I have written a very extremly long vbscript with many Subs/Functions.
Within each of the subs/functions I leave On Error Resume Next commented
out until I feel confident the script is functioning and I catch the
obvious issues. Once ready I enable "On Error Resume Next" with in all the
sub/functions.

Now since being used in production the script encountered a issue and it
happens its not an error I expected, so since On error command is used the
script continues even though there is an error. (As expected) To
troubleshoot the issue I had to comment out all the On Error lines to
actually disply the issue running.

In short when using On Error command is there any easier or better
approach when using On Erorr command and not having to comment the line
out.

My thoughts were to create a Constant OnError = True or False that is
gloabal, Then each time the command is used, do the following

Constant OnError = False

If OnError = True
On Error Resume Next
End If

I just don't know if thats the best away to approach and asking for any
ideas. The If statement will be teh same for each sub/function. A lot of
duplication of statement.



.



Relevant Pages

  • Re: on error resume next
    ... OnError Resume Next carries an enormous overhead ... I know some consider this unsightly, but my opinion is that I'd ... The only time I can see where you want a production script to use On Error ... In short when using On Error command is there any easier or better ...
    (microsoft.public.scripting.vbscript)
  • on error resume next
    ... I have written a very extremly long vbscript with many Subs/Functions. ... Now since being used in production the script encountered a issue and it ... In short when using On Error command is there any easier or better approach ... My thoughts were to create a Constant OnError = True or False that is ...
    (microsoft.public.scripting.vbscript)
  • Re: Earliest known Hebrew writing discovered?
    ... can have an opinion? ... probably is the earliest example of Hebrew ... Early Aramaic) script that is a very close variant of the Phoenician ... credits Ezra with rewriting the Torah in the new ...
    (soc.culture.jewish.moderated)
  • Re: Harriet Jones again
    ... >it being made up as RTD went along in the script. ... >introduction to a new series in my opinion - poor pilot, ...
    (rec.arts.drwho.moderated)
  • Re: Delphi Blogsphere
    ... > My real point is that if you don't allow JavaScript/ECMAScript, Flash, ... > you can only marginally claim to support HTML. ... > by posting a message with a syntax error in the script. ... It may be a well-informed opinion motivated by an uncanny grasp ...
    (borland.public.delphi.non-technical)