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.2206';
3              
4 2     2   1384 use Moose;
  2         5  
  2         22  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::TypeConstraint';
7              
8 2     2   16 use Moose::Util::TypeConstraints qw/find_type_constraint/;
  2         5  
  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   5 my $self = shift;
18 2         74 my $type_parameter = $self->type_parameter;
19 2         67 my $type = find_type_constraint( $self->type_name );
20 2         87 my $parent = $type->parent->type_parameter;
21              
22 2         13 return "$type_parameter is not a subtype of $parent";
23             }
24              
25             __PACKAGE__->meta->make_immutable;
26             1;