Next: ref-ere-int, Previous: ref-ere-exa, Up: ref-ere [Contents][Index]
Exception handling for Prolog was originally introduced in Quintus
Prolog, and later inherited by SICStus Prolog, with an API that predated
the ISO standard. This API is still supported but should be regarded as
legacy, and consists of the two predicates raise_exception/1
and
on_exception/3
:
on_exception(?Template, :ProtectedGoal, :Handler)
Equivalent to catch(:ProtectedGoal, ?Template,
:Handler)
. Any exception term matching Template is caught
and handled.
See mpg-ref-on_exception.
raise_exception(+ExceptionTerm)
If ExceptionTerm matches one of the SICStus error terms listed in
ref-ere-err, then the corresponding error term
error(ISO_Error, SICStus_Error)
is constructed and thrown.
Otherwise, ExceptionTerm is thrown as is.
Prior to release 4.3, throw/1
and raise_exception/3
used
to be equivalent and throw their argument as is, whereas catch/3
and on_exception/3
both used to attempt to recognize and expand
SICStus error terms into error/2
terms. Unless a forged SICStus
error term is thrown by throw/1
, the net behavior is unchanged.
See mpg-ref-raise_exception.