Existence Errors

An existence error occurs when a predicate attempts to access something that does not exist. For example, trying to compile a file that does not exist, erasing a database reference that has already been erased.

The SICStus_Error term associated with an existence error is

     existence_error(Goal, ArgNo, ObjectType, Culprit, Message)
index of argument of Goal where Culprit appears
expected type of non-existent object
name for the non-existent object
the constant 0 or '', or some additional information provided by the operating system or other support system indicating why Culprit is thought not to exist.

For example, ‘see('../brother/niece')’ might throw the exception


An existence error does not necessarily cause an exception to be thrown. For I/O predicates, the behavior can be controlled with the fileerrors Prolog flag (see ref-lps-flg) or with the fileerrors/1 alias file_errors/1 option to absolute_file_name/3. The following values are possible:

on (fileerrors flag value)
error (absolute_file_name/3 fileerrors value)
Throw an exception if a given file can't be opened. The default.
off (fileerrors flag value)
fail (absolute_file_name/3 fileerrors value)
Merely fail if a given file can't be opened.

Send feedback on this subject.