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