Next: , Previous: , Up: ref-ere-err   [Contents][Index]


4.15.4.7 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)
ArgNo

index of argument of Goal where Culprit appears

ObjectType

expected type of non-existent object

Culprit

name for the non-existent object

Message

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

error(existence_error(source_sink,'../brother/niece'),
      existence_error(see('../brother/niece'),1,file,'../brother/niece',0))

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 cannot be opened. The default.

off (fileerrors flag value)
fail (absolute_file_name/3 fileerrors value)

Merely fail if a given file cannot be opened.


Send feedback on this subject.