Users can write a handler for the specific exception occurring when an
undefined predicate is called by defining clauses for the hook
predicate user:unknown_predicate_handler/3
. This can be thought of as
a “global” exception handler for this particular exception, because
unlike on_exception/3
, its effect is not limited to a particular
goal. Furthermore, the exception is handled at the point where the
undefined predicate is called.
The handler can be written to apply to all unknown predicates, or to a class of them. The reference page contains an example of constraining the handler to certain predicates.