Exception handling in ISO Prolog

ISO Prolog provides an exception handling mechanism, based on the builtin control constructs catch/3 and throw/1. We describe here the ISO requirements for exception handling.

In effect when an error occurs the current goal is replaced by a goal

throw(error(Error_term, Implementation_defined_term))
Error_term -- is a term that supplies information about the error, and
Implementation_defined_term is an implementation defined term. In particular it may be ommitted.

Error Classification

Errors are classified according to the form of Error_term
There shall be an Instantiation Error when an argument or one of its components is a variable, and an instantiated argument or component is required. This error should therefor be raised whenever an argument of mode "+", or " @ " is encountered.
type_error(ValidType, Culprit)
There shall be a Type Error when the type of an argument or of one of its components is incorrect, but not a variable (which might be an instantiation_error).

ValidType is one of the following:

Note that the type term is universal in that it includes all types.

domain_error(ValidDomain, Culprit)
There shall be a Domain Error when the type of an argument is correct but the value is outside the domain for which the procedure is defined.

ValidDomain is one of the following:

existence_error(ObjectType, Culprit)
There shall be an Existence Error when the object on which an operation is to be performed does not exist.

ObjectType is one of the following:

permission_error(Operation, PermissionType, Culprit)
There shall be a Permission Error when it is not permitted to perform the specified operation on the given object.

Operation is one of:

and PermissionType is one of

There shall be a Representation Error when an implementation defined limit has been breached.In some cases the programmer can determine the allowed value using the built in predicate current_prolog_flag/2
Flag is one of
There shall be an Evaluation Error when the operands of an evaluable functor has an exceptional value.
Error is one of
There shall be a Resource Error at any stage of execution when the processor has insufficient resources to complete execution. Resource is an implementation defined term.
There shall be a Syntax Error when a sequence of characters which are bing input as a read_term
There may be a System Error at any stage of execution.
Using Exceptions
Return to Home Page of the INRIA ISO Prolog Web

Author: J.P.E. Hodgson
Inria Rocquencourt
78153 Le Chesnay Cedex

Saint Joseph's University
Philadelphia PA 19131

Last Changed: 12 April 1999