File Coverage

blib/lib/Data/Seek/Exception/RootInvalid.pm
Criterion Covered Total %
statement 12 24 50.0
branch 0 4 0.0
condition 0 2 0.0
subroutine 4 5 80.0
pod n/a
total 16 35 45.7


line stmt bran cond sub pod time code
1             # ABSTRACT: Data::Seek Invalid Root Exception Class
2             package Data::Seek::Exception::RootInvalid;
3              
4 4     4   908 use 5.10.0;
  4         12  
  4         173  
5              
6 4     4   20 use strict;
  4         9  
  4         122  
7 4     4   19 use warnings;
  4         5  
  4         121  
8              
9 4     4   852 use Mo;
  4         568  
  4         26  
10              
11             extends 'Data::Seek::Exception';
12              
13             our $VERSION = '0.05'; # VERSION
14              
15             has 'criterion';
16             has 'separator';
17             has 'subject';
18             has 'target';
19              
20             has 'is_array';
21             has 'is_ending';
22             has 'is_hash';
23             has 'is_match';
24              
25             sub _build_message {
26 0     0     my $self = shift;
27 0           my $is_array = $self->is_array;
28 0           my $is_hash = $self->is_hash;
29              
30 0 0         my $type = $is_hash ? 'AN OBJECT' : $is_array ? 'A LIST' : 'INVALID';
    0          
31              
32 0           my $criterion = $self->criterion;
33 0   0       my $separator = $self->separator // ' -> ';
34 0           my $subject = join $separator, @{$self->subject};
  0            
35 0           my $target = join $separator, @{$self->target};
  0            
36              
37 0           my $message = join ' ',
38             'ERROR MATCHING CRITERION (%s):',
39             'INVALID ENDING OF ROOT DATA/NODE (%s)',
40             'WHILE SEEKING (%s), NODE VALUE IS %s (NOT A STRING)';
41              
42 0           return sprintf $message, $criterion, $subject, $target, $type;
43             }
44              
45             1;
46              
47             __END__
48              
49             =pod
50              
51             =encoding UTF-8
52              
53             =head1 NAME
54              
55             Data::Seek::Exception::RootInvalid - Data::Seek Invalid Root Exception Class
56              
57             =head1 VERSION
58              
59             version 0.05
60              
61             =head1 SYNOPSIS
62              
63             use Data::Seek::Exception::NodeInvalid;
64              
65             =head1 DESCRIPTION
66              
67             Data::Seek::Exception::NodeInvalid is a module for is an exception class within
68             L<Data::Seek> which is thrown when a criterion references a root node within the
69             introspected data structure which is not what was expected.
70              
71             =head1 ATTRIBUTES
72              
73             =head2 criterion
74              
75             $exception->criterion;
76              
77             The criterion used against the data which resulted in the exception.
78              
79             =head2 separator
80              
81             $exception->separator;
82              
83             The separator used to denote the hierarchy of the match data and the criterion.
84              
85             =head2 subject
86              
87             $exception->subject;
88              
89             The hierarchy of the match data as an array reference.
90              
91             =head2 target
92              
93             $exception->target;
94              
95             The hierarchy of the criterion as an array reference.
96              
97             =head2 is_array
98              
99             $exception->is_array;
100              
101             True if the node is, during the exception being thrown, an array reference.
102              
103             =head2 is_ending
104              
105             $exception->is_ending;
106              
107             True if the node is, during the exception being thrown, the end of the structure.
108              
109             =head2 is_hash
110              
111             $exception->is_hash;
112              
113             True is the node is, during the exception being thrown, a hash reference.
114              
115             =head2 is_match
116              
117             $exception->is_match;
118              
119             True is the node has, during the exception being thrown, corresponding data.
120              
121             =encoding utf8
122              
123             =head1 AUTHOR
124              
125             Al Newkirk <anewkirk@ana.io>
126              
127             =head1 COPYRIGHT AND LICENSE
128              
129             This software is copyright (c) 2014 by Al Newkirk.
130              
131             This is free software; you can redistribute it and/or modify it under
132             the same terms as the Perl 5 programming language system itself.
133              
134             =cut