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
on_exception(?Template, :ProtectedGoal, :Handler)
:Handler). Any exception term matching Template is caught
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,
to be equivalent and throw their argument as is, whereas
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.