Currently we only have assertion/1 from
library(debug) described as
which throws an exception with a (non-ISO standard) formal term
assertion_error/2 if the
In fact, the exception thrown in case of
Goal equal to
This is similar to Java’s
assert(expr) (first added in Java 1.4 in 2002 only btw.)
assertion/1 can be compiled-out using expand_goal/2, if the
Goal is too expensive at runtime; I haven’t tried that yet.
It would be useful to have an
assertion/2 described as:
Closure is executed when
Goal fails with one additional uninstantiated argument, which shall be instantiated by the Closure, and which inserted into the second argument (the context term) of the
Then one could generate good error messages, similar to Java’s
assertion_handler(X,Y,T) :- with_output_to(string(T),format("This is bad. ~q < ~q; this rocket's gonna crash!!",[X,Y])).