Documentation for sub
die assembled from the following types:
multi sub die()multi sub die(*)multi sub die(Exception )method die(Exception:)
die "Important reason";
If the subroutine form is called without arguments, the value of
$! variable is checked. If it is set to a
.DEFINITE value, its value will be used as the Exception to throw if it's of type Exception, otherwise, it will be used as payload of X::AdHoc exception. If
$! is not
.DEFINITE, X::AdHoc with string
"Died" as payload will be thrown.
die will print by default the line number where it happens
die "Dead";# OUTPUT: «(exit code 1) Dead␤# in block <unit> at /tmp/dead.p6 line 1␤␤»
However, that default behavior is governed at the
Exception level and thus can be changed to anything we want by capturing the exception using
CATCH. This can be used, for instance, to suppress line numbers.
CATCH;die "Dead" # OUTPUT: «Dead␤»