Availability:built-in
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.
- exit
- Goal succeeded without leaving any choice points.
- fail
- 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).
- exception(Exception)
- Goal raised the given Exception.
- external_exception(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