File Coverage

blib/lib/Data/MultiValued/Exceptions.pm
Criterion Covered Total %
statement 18 24 75.0
branch n/a
condition 0 2 0.0
subroutine 6 8 75.0
pod 0 2 0.0
total 24 36 66.6


line stmt bran cond sub pod time code
1             package Data::MultiValued::Exceptions;
2             {
3             $Data::MultiValued::Exceptions::VERSION = '0.0.1_4';
4             }
5             {
6             $Data::MultiValued::Exceptions::DIST = 'Data-MultiValued';
7             }
8              
9             # ABSTRACT: exception classes
10              
11              
12             package Data::MultiValued::Exceptions::NotFound;
13             {
14             $Data::MultiValued::Exceptions::NotFound::VERSION = '0.0.1_4';
15             }
16             {
17             $Data::MultiValued::Exceptions::NotFound::DIST = 'Data-MultiValued';
18             }{
19 9     9   67 use Moose;
  9         18  
  9         100  
20             with 'Throwable';
21             use overload
22 9         98 q{""} => 'as_string',
23 9     9   72959 fallback => 1;
  9         56  
24              
25             has message => (
26             is => 'ro',
27             required => 1,
28             );
29              
30             has value => (
31             is => 'ro',
32             required => 1,
33             );
34              
35             sub as_string {
36 0     0 0   my ($self) = @_;
37              
38 0   0       my $str = $self->message . ($self->value // '<undef>');
39              
40 0           return $str;
41             }
42             }
43              
44              
45             package Data::MultiValued::Exceptions::TagNotFound;
46             {
47             $Data::MultiValued::Exceptions::TagNotFound::VERSION = '0.0.1_4';
48             }
49             {
50             $Data::MultiValued::Exceptions::TagNotFound::DIST = 'Data-MultiValued';
51             }{
52 9     9   1913 use Moose;
  9         27  
  9         60  
53             extends 'Data::MultiValued::Exceptions::NotFound';
54              
55             has '+message' => (
56             default => 'tag not found: ',
57             );
58             }
59              
60              
61             package Data::MultiValued::Exceptions::RangeNotFound;
62             {
63             $Data::MultiValued::Exceptions::RangeNotFound::VERSION = '0.0.1_4';
64             }
65             {
66             $Data::MultiValued::Exceptions::RangeNotFound::DIST = 'Data-MultiValued';
67             }{
68 9     9   75061 use Moose;
  9         33  
  9         139  
69             extends 'Data::MultiValued::Exceptions::NotFound';
70              
71             has '+message' => (
72             default => 'no range found for value: ',
73             );
74             }
75              
76              
77             package Data::MultiValued::Exceptions::BadRange;
78             {
79             $Data::MultiValued::Exceptions::BadRange::VERSION = '0.0.1_4';
80             }
81             {
82             $Data::MultiValued::Exceptions::BadRange::DIST = 'Data-MultiValued';
83             }{
84 9     9   80397 use Moose;
  9         26  
  9         52  
85             with 'Throwable';
86             use overload
87 9         81 q{""} => 'as_string',
88 9     9   73607 fallback => 1;
  9         39  
89              
90             has ['from','to'] => ( is => 'ro', required => 1 );
91              
92             sub as_string {
93 0     0 0   my ($self) = @_;
94              
95 0           my $str = 'invalid range: ' . $self->from . ', ' . $self->to;
96              
97 0           return $str;
98             }
99              
100             }
101              
102             1;
103              
104             __END__
105             =pod
106              
107             =encoding utf-8
108              
109             =head1 NAME
110              
111             Data::MultiValued::Exceptions - exception classes
112              
113             =head1 VERSION
114              
115             version 0.0.1_4
116              
117             =head1 DESCRIPTION
118              
119             This module defines a few exception classes, using L<Throwable::Error>
120             as a base class.
121              
122             =head1 CLASSES
123              
124             =head2 C<Data::MultiValued::Exceptions::NotFound>
125              
126             Base class for "not found" errors. Has a C<value> attribute,
127             containing the value that was not found.
128              
129             =head2 C<Data::MultiValued::Exceptions::TagNotFound>
130              
131             Subclass of L</Data::MultiValued::Exceptions::NotFound>, for
132             tags. Stringifies to:
133              
134             tag not found: $value
135              
136             =head2 C<Data::MultiValued::Exceptions::RangeNotFound>
137              
138             Subclass of L</Data::MultiValued::Exceptions::NotFound>, for
139             ranges. Stringifies to:
140              
141             no range found for value: $value
142              
143             =head2 C<Data::MultiValued::Exceptions::BadRange>
144              
145             Thrown when an invalid range is supplied to a method. An invalid range
146             is a range with C<from> greater than C<to>.
147              
148             Stringifies to:
149              
150             invalid range: $from, $to
151              
152             =head1 AUTHOR
153              
154             Gianni Ceccarelli <dakkar@thenautilus.net>
155              
156             =head1 COPYRIGHT AND LICENSE
157              
158             This software is copyright (c) 2011 by Net-a-Porter.com.
159              
160             This is free software; you can redistribute it and/or modify it under
161             the same terms as the Perl 5 programming language system itself.
162              
163             =cut
164