This module includes predicates related to exceptions and signals, which alter the normal flow of Prolog.
Executes Goal. If an exception is raised during its execution, Error is unified with the exception, and if the unification succeeds, the entire execution derived from Goal is aborted, and Handler is executed. The execution resumes with the continuation of the catch/3 call. For example, given the code
p(X) :- throw(error), display('---'). p(X) :- display(X).the execution of "catch(p(0), E, display(E)), display(.), fail." results in the output "error.".
Executes Goal. If a signal is sent during its execution, Signal is unified with the exception, and if the unification succeeds, Handler is executed and then the execution resumes after the point where the exception was thrown. To avoid infinite loops if Handler raises an exception which unifies with Error, the exception handler is deactivated before executing Handler. Note the difference with builtin catch/3, given the code
p(X) :- send_signal(error), display('---'). p(X) :- display(X).the execution of "intercept(p(0), E, display(E)), display(.), fail." results in the output "error---.0.".
Raises an error, throwing the exception Ball, to be caught by an ancestor catch/3. The closest matching ancestor is chosen. In addition to calls to throw/2 in user code, exceptions are also thrown by many library predicates in cases of error.
Emits a signal, to be intercepted by an ancestor intercept/3. The closest matching ancestor is chosen. If the signal is not intercepted, the following error is thrown: error(unintercepted_signal(Signal), send_signal/1-1).
Emits a signal as send_signal/1, but does not throw an error if the signal is not intercepted (i.e. just suceeds silently)
Halt the system, exiting to the invoking shell.
Halt the system, exiting to the invoking shell, returning exit code Code.
Abort the current execution.