|Did you know ...||Search Documentation:|
|General form of the ISO standard exception term|
The predicate throw/1
takes a single argument, the exception term, and the ISO
standard stipulates that the exception term be of the form
Thus, constructing an error term and throwing it might take this form (although you would not use the illustrative explicit naming given here; instead composing the exception term directly in a one-liner):
Exception = error(Formal, Context), Context = ... some local convention ..., Formal = type_error(ValidType, Culprit), % for "type error" for example ValidType = integer, % valid atoms are listed in the ISO standard Culprit = ... some value ..., throw(Exception)
Note that the ISO standard formal term expresses what should be the case or what is the expected correct state, and not what is the problem. For example:
instantiation_error: The problem is not that there is an unwanted instantiation, but that the correct state is the one with an instantiated variable.
uninstantiation_error(Culprit): The problem is not that there is lack of instantiation, but that the correct state is the one which Culprit (or one of its subterms) is more uninstantiated than is the case.
type_error(compound,). The problem is not that
is (erroneously) a compound term, but that a compound term is expected and
does not belong to that class.