File Coverage

blib/lib/Moose/Exception/ParameterIsNotSubtypeOfParent.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 14 14 100.0


line stmt bran cond sub pod time code
1             package Moose::Exception::ParameterIsNotSubtypeOfParent;
2             our $VERSION = '2.2205';
3              
4 2     2   1295 use Moose;
  2         6  
  2         15  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::TypeConstraint';
7              
8 2     2   22 use Moose::Util::TypeConstraints qw/find_type_constraint/;
  2         6  
  2         19  
9              
10             has 'type_parameter' => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1
14             );
15              
16             sub _build_message {
17 2     2   7 my $self = shift;
18 2         100 my $type_parameter = $self->type_parameter;
19 2         66 my $type = find_type_constraint( $self->type_name );
20 2         70 my $parent = $type->parent->type_parameter;
21              
22 2         26 return "$type_parameter is not a subtype of $parent";
23             }
24              
25             __PACKAGE__->meta->make_immutable;
26             1;