RWDE/Exceptions.pm untested

filter: Statementstmt 0.0% 0 / 87 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 122 CC 4 SCAR 15.9
CC
4
Cov
0%
new
20.0
is_retry
2.0
BEGIN
2.0
CRAP 4.9
1 package RWDE::Exceptions;
2  
3 use vars qw($VERSION);
4 $VERSION = sprintf "%d", q$Revision: 515 $ =~ /(\d+)/;
5  
6 =pod
7  
8 =head1 RWDE::Exceptions
9  
10 Exception container file, contains definitions for RWDE Exceptions
11  
12 System defined exceptions are based off of the default behaviour of this base exception class
13  
14 =cut
15  
16 =head1 Exception class definitions for RWDE
17  
18 =cut
19  
20 =head2 RWDE::BaseException()
21
22 =cut
23 package RWDE::BaseException;
24  
25 use strict;
26 use warnings;
27  
28 use RWDE::DB::DbRegistry;
29  
30 use base qw(Error);
31  
32 use overload ('""' => 'stringify');
33  
34 =head2 new()
35  
36 Override for the "new" method in the Error base class, initializes the instance the way we want.
37  
38 This will return an initialized instance of Error
39  
40 =cut
41  
42 sub new {
43 my ($proto, $params) = @_;
44  
45 my $class = ref($proto) || $proto;
46  
47 my $info = defined $$params{info} ? $$params{info} : 'none';
48 my $value = defined $$params{value} ? $$params{info} : 'none';
49  
50 if (defined $$params{abort_transaction}) {
51 RWDE::DB::DbRegistry->abort_transaction();
52 }
53  
54 local $Error::Depth = $Error::Depth + 1;
55 local $Error::Debug = 1; # Enables storing of stacktrace
56  
57 my $exception = $class->SUPER::new(-text => $info, -value => $value);
58  
59 return $exception;
60 }
61  
62 =head2 is_retry()
63  
64 Determine whether this was a retry attempt
65  
66 =cut
67  
68 sub is_retry {
69 my ($self) = @_;
70  
71 return $self->{'-value'} =~ m/retry/ig;
72 }
73  
74 1;
75  
76 =head1 Exception class definitions for RWDE
77  
78 =cut
79  
80 =head2 RWDE::DevelException()
81  
82 Caught with RWDE::DevelException - developer only exceptions, typically for unplanned behaviour
83  
84 =cut
85  
86 package RWDE::DevelException;
87 use base qw(RWDE::BaseException);
88  
89 1;
90  
91 =head2 RWDE::DataMissingException()
92  
93 caught with RWDE::DataMissingException - missing data detected
94  
95 =cut
96  
97 package RWDE::DataMissingException;
98 use base qw(RWDE::BaseException);
99 1;
100  
101 =head2 RWDE::DataBadException()
102  
103 Caught with RWDE::DataBadException - Invalid data detected
104  
105 =cut
106  
107 package RWDE::DataBadException;
108 use base qw(RWDE::BaseException);
109 1;
110  
111 =head2 RWDE::DataLimitException()
112  
113 Caught with RWDE::DataLimitException - Limit or threshold exceeded
114  
115 =cut
116  
117 package RWDE::DataLimitException;
118 use base qw(RWDE::BaseException);
119 1;
120  
121 =head2 RWDE::DataDuplicateException()
122  
123 Caught with RWDE::DataDuplicateException - Discovered duplicate data (typically db related)
124  
125 =cut
126  
127 package RWDE::DataDuplicateException;
128 use base qw(RWDE::BaseException);
129 1;
130  
131 =head2 RWDE::DataNotFoundException()
132  
133 Caught with RWDE::DataNotFoundException - Expected data does not exist
134  
135 =cut
136  
137 package RWDE::DataNotFoundException;
138 use base qw(RWDE::BaseException);
139 1;
140  
141 =head2 RWDE::BadPasswordException()
142  
143 Caught with RWDE::BadPasswordException - Problems accepting a password
144  
145 =cut
146  
147 package RWDE::BadPasswordException;
148 use base qw(RWDE::BaseException);
149 1;
150  
151 =head2 RWDE::SSLException()
152  
153 Caught with RWDE::SSLException - Problems with http SSL connections
154  
155 =cut
156  
157 package RWDE::SSLException;
158 use base qw(RWDE::BaseException);
159 1;
160  
161 =head2 RWDE::Web::SessionMissingException()
162  
163 Caught with RWDE::Web::SessionMissingException - Problem with the session occurred
164  
165 =cut
166  
167 package RWDE::Web::SessionMissingException;
168 use base qw(RWDE::BaseException);
169 1;
170  
171 =head2 RWDE::StatusException()
172  
173 Caught with RWDE::StatusException - Problem with instance status
174  
175 =cut
176  
177 package RWDE::StatusException;
178 use base qw(RWDE::BaseException);
179 1;
180  
181 =head2 RWDE::DatabaseErrorException()
182  
183 Caught with RWDE::DatabaseErrorException - Internal db problem detected
184  
185 =cut
186  
187 package RWDE::DatabaseErrorException;
188 use base qw(RWDE::BaseException);
189 1;
190  
191 =head2 RWDE::PolicyException()
192  
193 Caught with RWDE::PolicyException - Policy violation occurred
194  
195 =cut
196  
197 package RWDE::PolicyException;
198 use base qw(RWDE::BaseException);
199 1;
200  
201 =head2 RWDE::PermissionException()
202  
203 Caught with RWDE::PermissionException - Permission violation occurred
204  
205 =cut
206  
207 package RWDE::PermissionException;
208 use base qw(RWDE::BaseException);
209 1;
210  
211 =head2 RWDE::DefaultException()
212  
213 Caught with RWDE::DefaultException - Default Exception - undefined exceptions are funnelled here
214  
215 =cut
216  
217 package RWDE::DefaultException;
218 use base qw(RWDE::BaseException);
219 1;