This module includes predicates related to exceptions and signals, which alter the normal flow of execution.
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.".
Usage:ISO
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.".
Usage:
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.
Usage:ISOthrow(Term)
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).
Usage:send_signal(Term)
Emits a signal as send_signal/1, Intercepted=false if the signal is not intercepted (i.e. just suceeds) or true otherwise.
Usage:send_signal(Term,Intercepted)
Halt the system, exiting to the invoking shell.
Usage:ISO
Halt the system, exiting to the invoking shell, returning exit code Code.
Usage:ISO
Abort the current execution.