« blib/lib/Moose/Exception/PackageNameAndNameParamsNotGivenToWrap.pm
↑ Summary
blib/lib/Moose/Exception/ReferencesAreNotAllowedAsDefault.pm »
| 1 | package Moose::Exception::ParameterIsNotSubtypeOfParent; | ||
| 2 | 2 | our $VERSION = '2.4001'; | |
| 3 | |||
| 4 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | extends 'Moose::Exception'; | |
| 6 | 2 | with 'Moose::Exception::Role::TypeConstraint'; | |
| 7 | |||
| 8 | 2 | ▶ | use Moose::Util::TypeConstraints qw/find_type_constraint/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 2 | has 'type_parameter' => ( | |
| 11 | is => 'ro', | ||
| 12 | isa => 'Str', | ||
| 13 | required => 1 | ||
| 14 | ); | ||
| 15 | |||
| 16 | 2 | ▶ | sub _build_message { |
|
Subroutine
_build_message: called CC=1 SCAR=0.0
| |||
| 17 | 2 | my $self = shift; | |
| 18 | 2 | my $type_parameter = $self->type_parameter; | |
| 19 | 2 | my $type = find_type_constraint( $self->type_name ); | |
| 20 | 2 | my $parent = $type->parent->type_parameter; | |
| 21 | |||
| 22 | 2 | return "$type_parameter is not a subtype of $parent"; | |
| 23 | } | ||
| 24 | |||
| 25 | 2 | __PACKAGE__->meta->make_immutable; | |
| 26 | 2 | 1; | |