I'm trying to solve this issue, which mentions that the description of X::TypeCheck::Splice
exception in this page is wrong. This is the code:
use experimental :macros;
CATCH {
# will definitely catch all the exception
default { say .^name, " → ", .Str; }
}
macro a { 'foo' };
say a;
Which I have expanded to include the CATCH
block. However, an exception gets thrown:
===SORRY!===
Too few positionals passed; expected 3 arguments but got 2
However, I don't know if it's the correct type since it's not caught by the CATCH block. I have also tried to insert that block into CHECK
or BEGIN
phasers, which occur in compile time, to no avail. Any idea?
Apparently, other languages like clojure let the macro handle its own exception. That does not seem to work here; inserting the CATCH block inside the macro definition throws a WARNING, and kind of works (would print Nil
), which probably means it's catching the exception, but still does not print the exception type.
running your code through EVAL will throw the compile-time warning at run-time of the eval sub
EVAL q/use experimental :macros; macro a { "foo" }; say a/;
CATCH { default { .perl.say } };
# X::AdHoc.new(payload => "Too few positionals passed; expected 3 arguments but got 2")
As you can see, at least in this version it's an "untyped" exception. Those can also come from inside the VM, where more nuanced error handling isn't as easy as in Perl 6 or NQP code.
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