The syntax codeBlock whenExceptionDo: completionBlock runs the completion block if any exception occurs during the running of the code block. The completion block is not considered to have handled the exception. That is, a further exception handler is looked for after the completion block is run.
codeBlock whenExceptionDo: completionBlock
codeBlock when: ExAll do: [ :signal | completionBlock value. signal resumeBlock: nil signal signal ].
The syntax codeBlock atEndOrWhenExceptionDo: completionBlock causes the completion block to be run whether an exception occurs during the running of the code block, or the code block successfully runs to completion. As above, the completion block is not considered to have handled the exception. That is, a further exception handler is looked for after the completion block is run.
codeBlock atEndOrWhenExceptionDo: completionBlock
| cleanedUp | cleanedUp := false. codeBlock when: ExAll do: [ :signal | completionBlock value. cleanedUp := true. signal resumable: false. signal signal ]. cleanedUp ifFalse: [ completionBlock value ]
Note that completion blocks are not passed any arguments.