Lazy/ErrorHandler.pm

filter: Statementstmt 9.9% 12 / 121 Branchbran 0.0% 0 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 14.2% 3 / 21 Podpod 10.5% 2 / 19 totaltotal 9.0% 17 / 187 CC 14 SCAR 16.0
CC
14
Cov
8%
badConfig
6.0
badSession
6.0
badSessionExpiry
6.0
CRAP 5.0
« Lazy/CSS.pm ↑ Summary Lazy/Template.pm »
1 package CGI::Lazy::ErrorHandler;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use CGI::Lazy::Globals;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 #----------------------------------------------------------------------------------------
8 0 ▶sub badConfig {
Subroutine badConfig: not called CC=2 SCAR=17.9
Pod undocumented
9 0 my $self = shift;
10 0 my $filename = shift;
11  
12 0 my $msg = "Couldn't parse config file $filename: $@\n";
13  
14 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
15  
16 0 push @{$self->{_errors}}, $msg;
17  
18 0 return;
19 }
20  
21 #----------------------------------------------------------------------------------------
22 0 ▶sub badSession {
Subroutine badSession: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my $self = shift;
24 0 my $id = shift;
25  
26 0 my $msg = "Bad Session ID : $id\n";
27  
28 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
29  
30 0 push @{$self->{_errors}}, $msg;
31  
32 0 return;
33 }
34  
35 #----------------------------------------------------------------------------------------
36 0 ▶sub badSessionExpiry {
Subroutine badSessionExpiry: not called CC=2 SCAR=17.9
Pod undocumented
37 0 my $self = shift;
38  
39 0 my $msg = "Bad Session Config. Please check your config file or hash in the Session->{expires} key.\n";
40  
41 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
42  
43 0 push @{$self->{_errors}}, $msg;
44  
45 0 return;
46 }
47  
48 #----------------------------------------------------------------------------------------
49 0 ▶sub config {
Subroutine config: not called CC=1 SCAR=6.9
Pod undocumented
50 0 my $self = shift;
51  
52 0 return $self->q->config;
53 }
54  
55  
56 #----------------------------------------------------------------------------------------
57 0 ▶sub couldntOpenDebugFile {
Subroutine couldntOpenDebugFile: not called CC=2 SCAR=17.9
Pod undocumented
58 0 my $self = shift;
59 0 my $filename = shift;
60 0 my $error = shift;
61
62 0 my $msg = "Couldn't open Debugging Log file /tmp/$filename: $error\n";
63  
64 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
65  
66 0 push @{$self->{_errors}}, $msg;
67  
68 0 return;
69 }
70  
71 #----------------------------------------------------------------------------------------
72 0 ▶sub couldntOpenCssFile {
Subroutine couldntOpenCssFile: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my $self = shift;
74 0 my $docroot = shift;
75 0 my $cssdir = shift;
76 0 my $file = shift;
77 0 my $error = shift;
78  
79 0 my $msg = "Couldn't open CSS file $docroot$cssdir/$file: $error\n";
80
81 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
82  
83 0 push @{$self->{_errors}}, $msg;
84  
85 0 return;
86 }
87  
88 #----------------------------------------------------------------------------------------
89 0 ▶sub couldntOpenJsFile {
Subroutine couldntOpenJsFile: not called CC=2 SCAR=17.9
Pod undocumented
90 0 my $self = shift;
91 0 my $docroot = shift;
92 0 my $jsdir = shift;
93 0 my $file = shift;
94 0 my $error = shift;
95  
96 0 my $msg = "Couldn't open JS file $docroot$jsdir/$file: $error\n";
97  
98 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
99  
100 0 push @{$self->{_errors}}, $msg;
101
102 0 return;
103 }
104  
105 #----------------------------------------------------------------------------------------
106 0 ▶sub dbConnectFailed {
Subroutine dbConnectFailed: not called CC=2 SCAR=17.9
Pod undocumented
107 0 my $self = shift;
108  
109 0 my $msg = "Database connection failed: $@\n";
110  
111 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
112  
113 0 push @{$self->{_errors}}, $msg;
114  
115 0 return;
116 }
117  
118 #----------------------------------------------------------------------------------------
119 0 ▶sub dbError {
Subroutine dbError: not called CC=2 SCAR=17.9
Pod undocumented
120 0 my $self = shift;
121 0 my $pkg = shift;
122 0 my $file = shift;
123 0 my $line = shift;
124 0 my $query = shift;
125  
126 0 my $msg = "Database operation failed in $file calling $pkg at line $line :$@\ncalling: $query\n";
127  
128 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
129  
130 0 push @{$self->{_errors}}, $msg;
131  
132 0 return;
133 }
134  
135 #----------------------------------------------------------------------------------------
136 0 ▶sub dbReturnedMoreThanSingleValue {
Subroutine dbReturnedMoreThanSingleValue: not called CC=2 SCAR=17.9
Pod undocumented
137 0 my $self = shift;
138  
139 0 my ($pkg, $file, $line) = caller;
140  
141 0 my $msg = "Database lookup return more than a single value in $pkg called by $file at line $line\n";
142  
143 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
144  
145 0 push @{$self->{_errors}}, $msg;
146  
147 0 return;
148 }
149  
150 #----------------------------------------------------------------------------------------
151 0 ▶sub errorref {
Subroutine errorref: not called CC=1 SCAR=6.9
Pod documented
152 0 my $self = shift;
153  
154 0 return $self->{_errors};
155 }
156  
157 #----------------------------------------------------------------------------------------
158 0 ▶sub errors {
Subroutine errors: not called CC=1 SCAR=6.9
Pod documented
159 0 my $self = shift;
160  
161 0 return @{$self->{_errors}};
162 }
163  
164 #----------------------------------------------------------------------------------------
165 0 ▶sub getWithOtherThanArray {
Subroutine getWithOtherThanArray: not called CC=2 SCAR=17.9
Pod undocumented
166 0 my $self = shift;
167  
168 0 my ($pkg, $file, $line) = caller;
169  
170 0 my $msg = "DB get (get, getarray, gethashlist) called with something other than an array reference in $pkg called by $file at line $line. That won't fly.\n";
171  
172 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
173  
174 0 push @{$self->{_errors}}, $msg;
175  
176 0 return;
177 }
178  
179 #----------------------------------------------------------------------------------------
180 0 ▶sub noConfig {
Subroutine noConfig: not called CC=2 SCAR=17.9
Pod undocumented
181 0 my $self = shift;
182 0 my $filename = shift;
183  
184 0 my $msg = "Couldn't open config file $filename : $@\n";
185  
186 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
187  
188 0 push @{$self->{_errors}}, $msg;
189  
190 0 return;
191 }
192  
193 #----------------------------------------------------------------------------------------
194 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
195 1 my $class = shift;
196 1 my $q = shift;
197  
198 my $self = {
199 _q => $q,
200 _errors => [],
201 _silent => $q->vars->{silent},
202 1 };
203  
204 1 bless $self, $class;
205  
206 1 return $self;
207 }
208  
209 #----------------------------------------------------------------------------------------
210 0 ▶sub q {
Subroutine q: not called CC=1 SCAR=6.9
Pod undocumented
211 0 my $self = shift;
212  
213 0 return $self->{_q};
214 }
215  
216 #----------------------------------------------------------------------------------------
217 0 ▶sub tmplCreateError {
Subroutine tmplCreateError: not called CC=2 SCAR=17.9
Pod undocumented
218 0 my $self = shift;
219  
220 0 my $msg = "Template Creation Error: $@\n";
221  
222 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
223  
224 0 push @{$self->{_errors}}, $msg ;
225  
226 0 return;
227 }
228  
229 #----------------------------------------------------------------------------------------
230 0 ▶sub silent {
Subroutine silent: not called CC=1 SCAR=6.9
Pod undocumented
231 0 my $self = shift;
232  
233 0 return $self->{_silent};
234 }
235  
236 #----------------------------------------------------------------------------------------
237 0 ▶sub tmplParamError {
Subroutine tmplParamError: not called CC=2 SCAR=17.9
Pod undocumented
238 0 my $self = shift;
239 0 my $template = shift;
240  
241 0 my $msg = "Template Parameter Error in $template: $@\n";
242  
243 0 ▶ print STDERR $msg unless $self->silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->silent 0 0 0
244  
245 0 push @{$self->{_errors}}, $msg;
246  
247 0 return;
248 }
249  
250 1 1
251  
252 __END__
« Lazy/CSS.pm ↑ Summary Lazy/Template.pm »