catch/3

All exceptions, including those raised by built-ins and interruptions, can be caught by catchers. A catcher is a call in the form:
      catch(Goal,ExceptionPattern,Recovergoal)
which is equivalent to Goal, except when an exception is raised during the execution of Goal that unifies ExceptionPattern. When such an exception is raised, all of the bindings that have been performed on variables in Goal will be undone, and Recovergoal will be executed to handle the exception. Note that ExceptionPattern is unified with a renamed copy of the exception before Recovergoal is executed. Also note that only exceptions that are raised by a descendant call of Goal can be caught.



Subsections

Neng-Fa Zhou 2013-01-25