Util/Exception/Standard.pm

filter: Statementstmt 100% 28 / 28 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 88.3% 38 / 43 CC 3 SCAR 5.3
CC
3
Cov
91%
_errors
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« Util/Exception/Diagnostic.pm ↑ Summary
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package File::Util::Exception::Standard;
5 3 $File::Util::Exception::Standard::VERSION = '4.201720';
6 # ABSTRACT: Standard (non-verbose) error messages
7  
8 3 ▶use File::Util::Definitions qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use File::Util::Exception qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
12 @ISA $AUTHORITY
13 @EXPORT_OK %EXPORT_TAGS
14 3 );
15  
16 3 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 $AUTHORITY = 'cpan:TOMMY';
19 3 @ISA = qw( Exporter File::Util::Exception );
20 3 @EXPORT_OK = ( '_errors', @File::Util::Exception::EXPORT_OK );
21 3 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
22  
23  
24 #%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#
25 # STANDARD (NON-VERBOSE) ERROR MESSAGES
26 #%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#
27 1 ▶sub _errors {
Subroutine _errors: called CC=3 SCAR=12.0
28 1 my ( $this, $error_thrown ) = @_;
29  
30 1 ▶ $error_thrown ||= $this;
Condition33%1/3
$error_thrown ||= $this
l!l&&r!l&&!r
100
MC/DC0%0/2
$error_thrown ||= $this
$error_thrown $this
Truth table33%1/3
A ||= B
A= $error_thrownB= $this
ABresult
1X1
011
000
31  
32 # begin long table of helpful diag error messages
33 1 my %error_msg_table = (
34 # NO UNICODE SUPPORT
35 'no unicode' => <<'__no_unicode__',
36 Your version of Perl is not new enough to support unicode: $EBL$^V$EBR
37 __no_unicode__
38  
39  
40 # NO SUCH FILE
41 'no such file' => <<'__bad_open__',
42 File inaccessible or does not exist: $EBL$opts->{filename}$EBR
43 __bad_open__
44  
45  
46 # BAD FLOCK RULE POLICY
47 'bad flock rules' => <<'__bad_lockrules__',
48 Invalid file locking policy can not be implemented.
49 __bad_lockrules__
50  
51  
52 # CAN'T READ FILE - PERMISSIONS
53 'cant fread' => <<'__cant_read__',
54 Permissions conflict. Can't read: $EBL$opts->{filename}$EBR
55 __cant_read__
56  
57  
58 # CAN'T READ FILE - NOT EXISTENT
59 'cant fread not found' => <<'__cant_read__',
60 File not found: $EBL$opts->{filename}$EBR
61 __cant_read__
62  
63  
64 # CAN'T CREATE FILE - PERMISSIONS
65 'cant fcreate' => <<'__cant_write__',
66 Permissions conflict. Can't create: $EBL$opts->{filename}$EBR
67 __cant_write__
68  
69  
70 # CAN'T WRITE TO FILE - EXISTS AS DIRECTORY
71 'cant write_file on a dir' => <<'__bad_writefile__',
72 File already exists as directory: $EBL$opts->{filename}$EBR
73 __bad_writefile__
74  
75  
76 # CAN'T TOUCH A FILE - EXISTS AS DIRECTORY
77 'cant touch on a dir' => <<'__bad_touchfile__',
78 File already exists as directory: $EBL$opts->{filename}$EBR
79 __bad_touchfile__
80  
81  
82 # CAN'T WRITE TO FILE
83 'cant fwrite' => <<'__cant_write__',
84 Permissions conflict. Can't write to: $EBL$opts->{filename}$EBR
85 __cant_write__
86  
87  
88 # BAD OPEN MODE - PERL
89 'bad openmode popen' => <<'__bad_openmode__',
90 Illegal mode specified for file open: $EBL$opts->{badmode}$EBR
91 __bad_openmode__
92  
93  
94 # BAD OPEN MODE - SYSOPEN
95 'bad openmode sysopen' => <<'__bad_openmode__',
96 Illegal mode specified for sysopen: $EBL$opts->{badmode}$EBR
97 __bad_openmode__
98  
99  
100 # CAN'T LIST DIRECTORY
101 'cant dread' => <<'__cant_read__',
102 Permissions conflict. Can't list directory: $EBL$opts->{dirname}$EBR
103 __cant_read__
104  
105  
106 # CAN'T CREATE DIRECTORY - PERMISSIONS
107 'cant dcreate' => <<'__cant_dcreate__',
108 Permissions conflict. Can't create directory: $EBL$opts->{dirname}$EBR
109 __cant_dcreate__
110  
111  
112 # CAN'T CREATE DIRECTORY - TARGET EXISTS
113 'make_dir target exists' => <<'__cant_dcreate__',
114 make_dir target already exists: $EBL$opts->{dirname}$EBR
115 __cant_dcreate__
116  
117  
118 # CAN'T OPEN
119 'bad open' => <<'__bad_open__',
120 Can't open: $EBL$opts->{filename}$EBR for: $EBL$opts->{mode}$EBR
121 OS error if any: $EBL$!$EBR
122 __bad_open__
123  
124  
125 # BAD CLOSE
126 'bad close' => <<'__bad_close__',
127 Couldn't close: $EBL$opts->{filename}$EBR
128 OS error if any: $EBL$!$EBR
129 __bad_close__
130  
131  
132 # CAN'T TRUNCATE
133 'bad systrunc' => <<'__bad_systrunc__',
134 Couldn't truncate() on $EBL$opts->{filename}$EBR
135 OS error if any: $EBL$!$EBR
136 __bad_systrunc__
137  
138  
139 # CAN'T GET FLOCK AFTER BLOCKING
140 'bad flock' => <<'__bad_lock__',
141 Can't get a lock on the file: $EBL$opts->{filename}$EBR
142 OS error if any: $EBL$!$EBR
143 __bad_lock__
144  
145  
146 # CAN'T OPEN ON A DIRECTORY
147 'called open on a dir' => <<'__bad_open__',
148 Can't call open() on a directory: $EBL$opts->{filename}$EBR
149 __bad_open__
150  
151  
152 # CAN'T OPENDIR ON A FILE
153 'called opendir on a file' => <<'__bad_open__',
154 Can't opendir() on non-directory: $EBL$opts->{filename}$EBR
155 __bad_open__
156  
157  
158 # CAN'T MKDIR ON A FILE
159 'called mkdir on a file' => <<'__bad_open__',
160 Can't make directory; already exists as a file. $EBL$opts->{filename}$EBR
161 __bad_open__
162  
163  
164 # BAD CALL TO File::Util::read_limit
165 'bad read_limit' => <<'__read_limit__',
166 Bad input provided to read_limit().
167 __read_limit__
168  
169  
170 # EXCEEDED READ_LIMIT
171 'read_limit exceeded' => <<'__read_limit__',
172 Stopped reading: $EBL$opts->{filename}$EBR Read limit exceeded: $opts->{read_limit} bytes
173 __read_limit__
174  
175  
176 # BAD CALL TO File::Util::abort_depth
177 'bad abort_depth' => <<'__abort_depth__',
178 Bad input provided to abort_depth()
179 __abort_depth__
180  
181  
182 # EXCEEDED ABORT_DEPTH
183 'abort_depth exceeded' => <<'__abort_depth__',
184 Recursion limit exceeded at $EBL${\ scalar(
185 (exists $opts->{abort_depth} && defined $opts->{abort_depth}) ?
186 $opts->{abort_depth} : $ABORT_DEPTH)
187 }$EBR dives.
188 __abort_depth__
189  
190  
191 # BAD OPENDIR
192 'bad opendir' => <<'__bad_opendir__',
193 Can't opendir on directory: $EBL$opts->{dirname}$EBR
194 OS error if any: $EBL$!$EBR
195 __bad_opendir__
196  
197  
198 # BAD MAKEDIR
199 'bad make_dir' => <<'__bad_make_dir__',
200 Can't create directory: $EBL$opts->{dirname}$EBR
201 OS error if any: $EBL$!$EBR
202 __bad_make_dir__
203  
204  
205 # BAD CHARS
206 'bad chars' => <<'__bad_chars__',
207 String contains illegal characters: $EBL$opts->{string}$EBR
208 __bad_chars__
209  
210  
211 # NOT A VALID FILEHANDLE
212 'not a filehandle' => <<'__bad_handle__',
213 Can't unlock file with an invalid file handle reference
214 __bad_handle__
215  
216  
217 # BAD CALL TO METHOD FOO
218 'no input' => <<'__no_input__',
219 Call to $EBL$opts->{meth}()$EBR failed: @{[
220 $opts->{missing} ? $EBL . $opts->{missing} . $EBR : undef || 'Required input'
221 ]} missing
222 __no_input__
223  
224  
225 # CAN'T USE UTF8 WITH SYSOPEN
226 'bad binmode' => <<'__bad_binmode__',
227 The use of system IO (sysread/syswrite/etc) on utf8 file handles is deprecated.
228 Please don't specify { use_sysopen => 1 } together with { binmode => 'utf8' }
229 __bad_binmode__
230  
231  
232 # PLAIN ERROR TYPE
233 'plain error' => <<'__plain_error__',
234 ${\ scalar ($_[0] || ((exists $opts->{error} && defined $opts->{error}) ?
235 $opts->{error} : '[error unspecified]')) }
236 __plain_error__
237  
238  
239 # INVALID ERROR TYPE
240 'unknown error message' => <<'__foobar_input__',
241 Failed with an invalid error-type designation.
242 This is a bug! Please File A Bug Report!
243 __foobar_input__
244  
245  
246 # EMPTY ERROR TYPE
247 'empty error' => <<'__no_input__',
248 Failed with an empty error-type designation.
249 __no_input__
250  
251 ); # end of error message table
252  
253 exists $error_msg_table{ $error_thrown }
254 ? $error_msg_table{ $error_thrown }
255 1 ▶ : $error_msg_table{'unknown error message'}
Branch: 1 branch
BranchTrueFalseTotal
exists $error_msg_table{$error_thrown} ? : 1 0 1
256 }
257  
258  
259 # --------------------------------------------------------
260 # File::Util::Exception::Standard::DESTROY()
261 # --------------------------------------------------------
262 1 ▶sub DESTROY { }
Subroutine DESTROY: called CC=1 SCAR=0.0
263  
264  
265 3 1;
266  
267  
268 __END__
« Util/Exception/Diagnostic.pm ↑ Summary