Prolog Language Error handling and exceptions Type and domain errors


A type error occurs if an argument is not of the expected type. Examples of types are:

  • integer
  • atom
  • list.

If the predicate is of the expected type, but outside the expected domain, then a domainĀ error is raised.

For example, a domain error is admissible if an integer between 0 and 15 is expected, but the argument is the integerĀ 20.

Declaratively, a type or domain error is equivalent to silent failure, since no instantiation can make a predicate whose argument is of the wrong type or domain succeed.