Since 0.25.0 version it is possible to use
error
object just like this:
[x] > check
if. > @
x.eq 0
error "Can't divide by zero"
42.div x
Here, the object error
causes program termination at the first attempt to dataize it.
It encapsulates any other object, which can play the role of an exception that is
floating to the upper level.
The object try
enables the catching of an error
objects and extracting exceptions from them.
For example, the following code prints “The 1th argument of ‘int.div’ is invalid: division by zero is infinity” and then “finally”:
QQ.try
[]
42.div 0 > @
[e]
QQ.io.stdout > @
e
[]
QQ.io.stdout > @
"finally"
The object error
encapsulates the error message from int.div
object and terminates the program.