This section describes the predicate exception/3,
which may be defined by the user in the module user
as a
multifile predicate. Unlike the name suggests, this is actually a hook
predicate. Exceptions are handled by the ISO predicates catch/3
and throw/1.
They all frames created after the matching catch/3
to be discarded immediately.
The predicate exception/3 is called by the kernel on a couple of events, allowing the user to alter the behaviour on some predefined events.
undefined_predicate
Context
is instantiated to a term Name/Arity. Name
refers to the name and Arity to the arity of the undefined
predicate. If the definition module of the predicate is not user, Context
will be of the form <Module>:<Name>/<Arity>.
If the predicate fails Prolog will generate an esistence_error
exception. If the predicate succeeds it should instantiate the last
argument either to the atom fail
to tell Prolog to fail the
predicate, the atom
retry
to tell Prolog to retry the predicate or error
to make the system generate an exception. The action retry
only makes sense if the exception handler has defined the predicate.