Error Handling
06/2005
Danaher Motion
158 Rev
E
M-SS-005-03l
During the internal error action, the synchronous error is logged in the MC
and the task is idled. The default system error handler stops all motion and
all attached tasks.
In the figure above, there are two mechanisms for trapping and dealing with
errors:
OnError
and
Try/Finally
blocks. These two error-handling
mechanisms allow you to write your program to respond to errors.
11.1.1.1.
O
N
E
RROR
The
OnError
block is handled like an event handler. An event handler lets
your program respond to events. The
OnError
block allows your program to
catch errors.
OnError
overrides default system error action if
OnError
traps
error. Main program execution is stopped while the
OnError
block is
executing and must be resumed if that is desired. An example of this is
shown later in this section.
Add an
OnError
code block to your program between the
Program
and
End
Program
section of your program.
The number of
Catch
statements in an
OnError
block is not explicitly limited.
Catch Else
may optionally be used. If you want a task to resume after an
error has occurred, use
CONTINUETASK
.
You can use
GoTo
within the error handler. However, because
OnError
interrupts the main program, you cannot use
GoTo
to branch outside the
error handler. You cannot place an
OnError
block in the middle of program
flow. The scope of
OnError
is that of the task withing which it is contained. It
only handlers errors that occur within that task.