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.2205';
3              
4 4     4   3045 use Moose;
  4         16  
  4         34  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::TypeConstraint';
7              
8 4     4   36 use Moose::Util::TypeConstraints 'find_type_constraint';
  4         12  
  4         39  
9              
10             has 'package_defined_in' => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1,
14             );
15              
16             sub _build_message {
17 32     32   73 my $self = shift;
18 32         1115 my $type_name = $self->type_name;
19 32         105 my $type = find_type_constraint( $type_name );
20 32         1454 my $type_package_defined_in = $type->_package_defined_in;
21 32         1142 my $package_defined_in = $self->package_defined_in;
22 32         832 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;