File Coverage

blib/lib/Moose/Exception/TypeConstraintIsAlreadyCreated.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Moose::Exception::TypeConstraintIsAlreadyCreated;
2             our $VERSION = '2.2206';
3              
4 4     4   3040 use Moose;
  4         16  
  4         30  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::TypeConstraint';
7              
8 4     4   42 use Moose::Util::TypeConstraints 'find_type_constraint';
  4         10  
  4         40  
9              
10             has 'package_defined_in' => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1,
14             );
15              
16             sub _build_message {
17 32     32   67 my $self = shift;
18 32         1064 my $type_name = $self->type_name;
19 32         110 my $type = find_type_constraint( $type_name );
20 32         1125 my $type_package_defined_in = $type->_package_defined_in;
21 32         1176 my $package_defined_in = $self->package_defined_in;
22 32         842 return "The type constraint '$type_name' has already been created in $type_package_defined_in and cannot be created again in $package_defined_in";
23             }
24              
25             __PACKAGE__->meta->make_immutable;
26             1;