In addition to success and failure, a program may give an exception that is thrown explicitly by a call of throw/2 or raised by a built-in or caused by your typing of control-c. An exception raised by a built-in is an one-argument structure where the functor tells the type and the argument tells the source of the exception.5.1
The following lists some of the exceptions:
- divide_by_zero(Goal): Goal divides a number by zero.
- file_not_found(Goal): Goal tries to open a file that does not exist.
- illegal_arguments(Goal): Goal has an illegal argument.
- number_expected(Goal): Goal evaluates an invalid expression.
- out_of_range(Goal): Goal tries to access an element of a structure or an array using an index that is out of range.
The exception caused by the typing of control-c is an atom named interrupt.
An exception that is not caught by your program will be handled by the system. The system reports the type and the source of the exception,
and aborts execution of the query. For example, for the query a=:=1, the system will
report:
*** error(type_error(evaluable,a/0),=:=/2)
where evaluable is the type and =:=/2 is the source.
Neng-Fa Zhou
2012-01-03