Skip Menu |

This queue is for tickets about the Throwable-Factory CPAN distribution.

Report information
The Basics
Id: 84277
Status: resolved
Priority: 0/
Queue: Throwable-Factory

People
Owner: perl [...] toby.ink
Requestors: cpan [...] prather.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.005
Fixed in: (no value)



Subject: Class based dispatching doesn't work.
So as I mentioned via phenny on irc.perl.org ->isa('StructName') fails for MooX::Struct classes. This means that documented features in Throwable::Factory do not in fact when changed *slightly* from the documentation. The specific case is using the example from the POD of Try::Tiny::ByClass. The example in the pod *does work* ... but not in the way in which someone (at least I) expect. If I take out the '-notimplemented' flag and no longer compose the Role the exception will fall through entirely. Here's the example stripped down demonstrating the issue. ----- #!/usr/bin/env perl use 5.12.1; use Try::Tiny::ByClass; use Throwable::Factory # ErrTooBig => [qw( $maximum! )], # falls through the try/catch ErrTooBig => [qw( $maximum! -notimplemented )], # gets caught because it applies a Role. ; try { ErrTooBig->throw(message => 'Ugh!', maximum => 12); } catch_case [ ErrTooBig => sub { warn "Too big!" }, 'Throwable::Taxonomy::NotImplemented' => sub { warn "Not Implemented?" }, ];
You want: +ErrTooBig => sub { warn "Too big!" }, This is because ErrToBig is not a string, but a function with prototype (). The fat comma causes it to be quoted as a string. The plus sign is included in the documentation example, but arguably more attention should be drawn to it.
Documentation updated in 0.006