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