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.2203';
3              
4 4     4   2662 use Moose;
  4         13  
  4         26  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::TypeConstraint';
7              
8 4     4   33 use Moose::Util::TypeConstraints 'find_type_constraint';
  4         9  
  4         37  
9              
10             has 'package_defined_in' => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1,
14             );
15              
16             sub _build_message {
17 32     32   63 my $self = shift;
18 32         1011 my $type_name = $self->type_name;
19 32         103 my $type = find_type_constraint( $type_name );
20 32         1123 my $type_package_defined_in = $type->_package_defined_in;
21 32         1121 my $package_defined_in = $self->package_defined_in;
22 32         776 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;