up previous next
try --
try command sequence, catch any errors
|
Try C1 UponError E Do C2 EndTry
where C1, C2 are sequences of commands and E is a variable identifier.
|
Usually, when an error occurs during the execution of a command, the
error is automatically propagated out of the nesting of the
evaluation. This can be prevented with the use of
Try..UponError
.
If an error occurs during the execution of the commands
C1
, then it is
captured by the command
UponError
and assigned to the variable
E
,
and the commands
C2
are executed; the string inside
E
may be
retrieved using
GetErrMesg
. If no error occurs then the variable
E
and the commands
C2
are ignored.
/**/ -- Equality function allowing mixed types:
/**/ Define AreEqual(A,B)
/**/ Try
/**/ Return A = B;
/**/ UponError E Do
/**/ Return false;
/**/ EndTry;
/**/ EndDefine;
/**/ AreEqual(0, "zero");
false
/**/ AreEqual(1+2, 3);
true
|