tokuhirom's Blog

[Perl6] how do i debug if got an exception from internal methods

I got a Cannot use a Buf as a string, but you called the Stringy method on it excetption.

It comes from X::Buf::AsStr exception class.

my class X::Buf::AsStr is Exception {
    has $.method;
    method message() {
        "Cannot use a Buf as a string, but you called the $.method method on it";
    }
}

But this method doesn't tell me an information to debug.

In this case, you can use --ll-exception option for perl6-m command.

It allows to show full backtrace includes internal method call.

In this case, I called "hoge".encode('ascii') eq "hoge". eq operator calls .Stringy method automatically.