Overview
The abort statement is a convenient shortcut to terminate the current transaction evaluation due to an error.
The syntax of the abort statement is:
abort <error_message> when [not] <expression>.
For example:
abort "I should not be negative" when I < 0.
or, equivalently:
abort "I should not be negative" when not I >= 0.
Abort During Initialization
There is a special syntactic form of the abort statement designed to work in combination (and only in combination) with variable initialization. In this case, rather than <expression>, the statement ends in is [not] <value>. This variation is most frequently used to eliminate NIL from an expression’s result set.
For example:
X = some_func some_argument abort "function returned NIL" when is NIL.
The type of
Xis inferred by the compiler as not nullable because the evaluator never allowsXto be equal toNILin this situation.