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.2203';
3              
4 2     2   1320 use Moose;
  2         5  
  2         16  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::TypeConstraint';
7              
8 2     2   15 use Moose::Util::TypeConstraints qw/find_type_constraint/;
  2         5  
  2         25  
9              
10             has 'type_parameter' => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1
14             );
15              
16             sub _build_message {
17 2     2   4 my $self = shift;
18 2         77 my $type_parameter = $self->type_parameter;
19 2         60 my $type = find_type_constraint( $self->type_name );
20 2         54 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;