By default, Raku's "die" reports the line number where the "die" is located, what if you'd like the line number of the calling context, ala "carp" with perl 5?
There is no direct equivalent to carp
, but you can start raku with the --ll-exception
parameter, which will create a full stack trace on an execution error.
I guess nobody has gotten around to creating a Carp
module yet. Creating a carp
sub shouldn't be too difficult, given that there is a Backtrace
class:
$ raku -e 'say "file: {.file}:{.line}" for Backtrace.new'
file: SETTING::src/core.c/Backtrace.pm6:94
file: SETTING::src/core.c/Backtrace.pm6:94
file: -e:1
There is now a Carp module available on GitHub and should soon be available in the Raku ecosystem. It currently only supports the most basic functionality, but over time it should be improved.
So the answer to your question is to use Carp like you would in Perl 5. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With