Exceptions raised by the Prolog system are called errors. The set of exception classes used by the system has been kept small. Here is a complete list:
The exception codes corresponding to these classes are:
instantiation_error(
Goal, ArgNo)
type_error(
Goal, ArgNo, TypeName, Culprit)
domain_error(
Goal, ArgNo, DomainName, Culprit, Message)
range_error(
Goal, ArgNo, TypeName, Culprit)
representation_error(
Goal, ArgNo, Message)
existence_error(
Goal, ArgNo, ObjectType, Culprit, Message)
permission_error(
Goal, Operation, ObjectType, Culprit, Message)
context_error(
Goal, ContextType, CommandType)
consistency_error(
Goal, Culprit1, Culprit2, Message)
syntax_error(
Goal, Position, Message, Left, Right)
resource_error(
Goal, Resource, Message)
system_error(
Message)
Most exception codes include a copy of the Goal that raised the exception.
In general, built-in predicates that cause side-effects, such as the opening of a stream or asserting a clause into the Prolog database, attempt to do all error checking before the side-effect is performed. Unless otherwise indicated in the documentation for a particular predicate or error class, it should be assumed that goals that raise exceptions have not performed any side-effect.