Whenever the Prolog system encounters a situation where it cannot continue
execution, it throws an exception. For example, if a built-in predicate
detects an argument of the wrong type, it throws a
exception. The manual page description of each built-in predicate lists the
kinds of exceptions that can be thrown by that built-in predicate.
The default effect of throwing an exception is to terminate the current computation and then print an error message. After the error message, you are back at Prolog’s top-level. For example, if the goal
X is a/2
is executed somewhere in a program you get
! Type error in argument 2 of (is)/2 ! expected evaluable, but found a/0 ! goal: _255 is a/2 | ?-
Particular things to notice in this message are:
This character indicates that this is an error message rather than a warning4 or informational message.
This is the error class. Exceptions thrown by the Prolog system are called errors. Every error is categorized into one of a small number of classes. The classes are listed in ref-ere-err.
The goal that caused the exception to be thrown.
Built-in predicates check their arguments, but predicates exported by library modules generally don’t, although some do check their arguments to a lesser or greater extent.
The difference between an error (including exceptions) and a warning: A warning is issued if Prolog detects a situation that is likely to cause problems, though it is possible that you intended it. An error, however, indicates that Prolog recognizes a situation where it cannot continue.