File Coverage

blib/lib/Data/Seek/Exception/NodeInvalid.pm
Criterion Covered Total %
statement 12 27 44.4
branch 0 4 0.0
condition 0 2 0.0
subroutine 4 5 80.0
pod n/a
total 16 38 42.1


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