File Coverage

blib/lib/MooseX/Attribute/ValidateWithException/Exception.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 22 100.0


line stmt bran cond sub pod time code
1             ## no critic (Moose::RequireMakeImmutable)
2 2     2   13195 use 5.006; # warnings
  2         5  
3 2     2   7 use strict;
  2         3  
  2         42  
4 2     2   7 use warnings;
  2         20  
  2         160  
5              
6             package MooseX::Attribute::ValidateWithException::Exception;
7              
8             our $VERSION = 'v0.4.0';
9              
10             # ABSTRACT: An Exception object to represent "Normal" moose validation failures.
11              
12             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13              
14 2     2   423 use Moose qw( extends has );
  2         294502  
  2         14  
15              
16             #with 'StackTrace::Auto';
17              
18             extends 'Throwable::Error';
19              
20             has 'attribute_name' => (
21             isa => 'Str',
22             required => 1,
23             is => 'ro',
24             );
25              
26             has 'data' => (
27             is => 'ro',
28             required => 1,
29             );
30              
31             has 'constraint_message' => (
32             is => 'ro',
33             required => 1,
34             );
35              
36             # has 'constraint' => (
37             # is => 'ro',
38             # required => 1,
39             #);
40              
41             has 'constraint_name' => (
42             isa => 'Str',
43             is => 'ro',
44             required => 1,
45             );
46              
47             has message => (
48             isa => 'Str',
49             is => 'ro',
50             lazy => 1,
51             builder => '_generate_message',
52             );
53              
54             sub _generate_message {
55 1     1   3 my ($self) = shift;
56 1         58 return sprintf 'Attribute (%s) does not pass the type constraint because: %s', $self->attribute_name, $self->constraint_message;
57             }
58              
59             #with 'StackTrace::Auto';
60              
61             __PACKAGE__->meta->make_immutable( inline_constructor => 0 );
62 2     2   8173 no Moose;
  2         3  
  2         7  
63             1;
64              
65             __END__
66              
67             =pod
68              
69             =encoding UTF-8
70              
71             =head1 NAME
72              
73             MooseX::Attribute::ValidateWithException::Exception - An Exception object to represent "Normal" moose validation failures.
74              
75             =head1 VERSION
76              
77             version v0.4.0
78              
79             =head1 AUTHOR
80              
81             Kent Fredric <kentnl@cpan.org>
82              
83             =head1 COPYRIGHT AND LICENSE
84              
85             This software is copyright (c) 2017 by Kent Fredric <kentnl@cpan.org>.
86              
87             This is free software; you can redistribute it and/or modify it under
88             the same terms as the Perl 5 programming language system itself.
89              
90             =cut