Introduction to Error Handling
'Best Practice' dictates that we should take steps to control errors.
Another reason for error handling is that it saves time troubleshooting when
you can narrow down the problem to one section of the script. In
practice you have three, choices, write a statement that says ignore errors
and carry on processing, allow errors to surface naturally, or add error
handling statements (best), which will give you valuable information on
where in the script the error is arising.
What the 'On Error Resume Next' statement does is defer error handling,
and suppress a system message. The script will carry on running but
you may be storing up problems. There is counter statement called 'On Error GoTo 0'
which turns off 'On Error Resume Next'. This means that you can have
different error handling for different sections of you script.
On Error Resume Next
Err.Clear
Set objContainer = GetObject("LDAP://" & strOUContainer)
Note 1: Without an 'On Error Resume Next' command, any run-time error will result
in pop-up message box with an error message and the code will execute no
further than the error.
|