File Coverage

blib/lib/Moose/Exception/ValidationFailedForTypeConstraint.pm
Criterion Covered Total %
statement 8 8 100.0
branch 2 2 100.0
condition n/a
subroutine 2 2 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Moose::Exception::ValidationFailedForTypeConstraint;
2             our $VERSION = '2.2206';
3              
4 19     19   13050 use Moose;
  19         56  
  19         168  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::Attribute';
7              
8             has 'value' => (
9             is => 'ro',
10             isa => 'Any',
11             required => 1,
12             );
13              
14             has 'type' => (
15             is => 'ro',
16             isa => Moose::Util::TypeConstraints->duck_type(["get_message", "name"]),
17             required => 1
18             );
19              
20             sub _build_message {
21 949     949   1609 my $self = shift;
22              
23 949         30758 my $error = $self->type->get_message( $self->value );
24              
25 949 100       37933 return $error unless $self->is_attribute_set;
26              
27 946         27426 my $attribute_name = $self->attribute->name;
28             return
29 946         21599 "Attribute ($attribute_name) does not pass the type constraint because: $error";
30             }
31              
32             __PACKAGE__->meta->make_immutable;
33             1;