4.15.1 Overview

Whenever the Prolog system encounters a situation where it cannot continue execution, it raises an exception. For example, if a built-in predicate detects an argument of the wrong type, it raises a type_error exception. The manual page description of each built-in predicate lists the kinds of exceptions that can be raised by that built-in predicate.

The default effect of raising 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 number, but found a
     ! goal:  A is a/2
     
     | ?-

Particular things to notice in this message are:

!
This character indicates that this is an error message rather than a warning1 or informational message.
Type Error
This is the exception class. Every exception raised by the system is categorized into one of a small number of classes. The classes are listed in ref-ere-err.
goal:
The goal that caused the exception to be raised.

Footnotes

[1] 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.



Send feedback on this subject.