If an exception is signaled while the code in an ensure block is being executed, and if the exception is not resumable or the exception handler does not end with a #resume, the ensure block will be restarted.
The following example demonstrates the problem:
run
| p stopEnsure |
stopEnsure := false.
p := [ [ [] ensure:
[ GsFile stdout log: 'Executing ensure block'.
[ stopEnsure ] whileFalse: [ 5000 factorial ]]]
on: Error
do: [:e | GsFile stdout log: 'Error signalled']]
forkAt: 12.
(Delay forSeconds: 1) wait.
p signalException: (Error new details: 'error').
(Delay forSeconds: 1) wait.
stopEnsure := true.
%
If the error being signaled is resumable (a Notification in the example rather than an Error) and the exception handler code ends with a resume, then the code behaves properly
Last updated: 2/5/15