setup_call_cleanup(Setup, Goal, Cleanup)with additional information on the reason for calling Cleanup. Prior to calling Cleanup, Catcher unifies with the termination code (see below). If this unification fails, Cleanup is not called.
- Goal succeeded without leaving any choice points.
- Goal failed.
- Goal succeeded with choice points and these are now discarded by the execution of a cut (or other pruning of the search tree such as if-then-else).
- Goal raised the given Exception.
- Goal succeeded with choice points and these are now discarded
due to an exception. For example:
?- setup_call_catcher_cleanup(true, (X=1;X=2), Catcher, writeln(Catcher)), throw(ball). external_exception(ball) ERROR: Unhandled exception: Unknown message: ball