Error::Pure::Utils - Utilities for structured errors.
use Error::Pure::Utils qw(clean err_get err_helper err_msg err_msg_hr); clean(); my @errors = err_get($clean); my @err_msg = err_msg($index); my $err_msg_hr = err_msg_hr($index); my @errors = err_helper('This is a fatal error', 'name', 'value');
clean()
Resets internal variables with errors. It is exportable. Returns undef.
err_get([$clean])
Get and clean processed errors. err_get() returns error structure. err_get(1) returns error structure and delete it internally. It is exportable. Returns array of errors.
err_msg([$index])
Get $index error messages array. If $index isn't present, use -1 as last message. Is is usable in situation >>err 'Error', 'item1', 'item2', 'item3', 'item4'<<. Then returns ('Error', 'item1', 'item2', 'item3', 'item4') array. See EXAMPLE2. It is exportable. Returns array of error messages.
err_msg_hr([$index])
Get $index error message key, value pairs as hash reference. If $index isn't present, use -1 as last message. Is is usable in situation >>err 'Error', 'key1', 'val1', 'key2', 'val2'<<. Then returns {'key1' => 'val1', 'key2' => 'val2'} structure. See EXAMPLE3. It is exportable. Returns reference to hash with error messages.
err_helper(@msg)
Subroutine for additional module above Error::Pure. @msg is array of messages. It is exportable. Returns array of errors.
$LEVEL
Default value is 2.
$MAX_LEVELS
Default value is 50.
$MAX_EVAL
Default value is 100.
$MAX_ARGS
Default value is 10.
$MAX_ARG_LEN
$PROGRAM
Program name in stack information. Default value is ''.
# Pragmas. use strict; use warnings; # Modules. use Dumpvalue; use Error::Pure::Die qw(err); use Error::Pure::Utils qw(err_get); # Error in eval. eval { err '1', '2', '3'; }; # Error structure. my @err = err_get(); # Dump. my $dump = Dumpvalue->new; $dump->dumpValues(\@err); # In \@err: # [ # { # 'msg' => [ # '1', # '2', # '3', # ], # 'stack' => [ # { # 'args' => '(1)', # 'class' => 'main', # 'line' => '9', # 'prog' => 'script.pl', # 'sub' => 'err', # }, # { # 'args' => '', # 'class' => 'main', # 'line' => '9', # 'prog' => 'script.pl', # 'sub' => 'eval {...}', # }, # ], # }, # ],
# Pragmas. use strict; use warnings; # Modules. use English qw(-no_match_vars); use Error::Pure qw(err); use Error::Pure::Utils qw(err_msg); # Error in eval. eval { err 'Error', 'item1', 'item2', 'item3', 'item4'; }; if ($EVAL_ERROR) { my @err_msg = err_msg(); foreach my $item (@err_msg) { print "$item\n"; } } # Output: # Error # item1 # item2 # item3 # item4
# Pragmas. use strict; use warnings; # Modules. use English qw(-no_match_vars); use Error::Pure qw(err); use Error::Pure::Utils qw(err_msg_hr); # Error in eval. eval { err 'Error', 'key1', 'val1', 'key2', 'val2'; }; if ($EVAL_ERROR) { print $EVAL_ERROR; my $err_msg_hr = err_msg_hr(); foreach my $key (sort keys %{$err_msg_hr}) { print "$key: $err_msg_hr->{$key}\n"; } } # Output: # Error # key1: val1 # key2: val2
Cwd, Exporter, Readonly.
Error::Pure, Error::Pure::AllError, Error::Pure::Error, Error::Pure::ErrorList, Error::Pure::HTTP::AllError, Error::Pure::HTTP::Error, Error::Pure::HTTP::ErrorList, Error::Pure::HTTP::Print, Error::Pure::Output::Text, Error::Pure::Print.
https://github.com/tupinek/Error-Pure
Michal Špaček mailto:skim@cpan.org
http://skim.cz
BSD 2-Clause License
0.17
To install Error::Pure, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Error::Pure
CPAN shell
perl -MCPAN -e shell install Error::Pure
For more information on module installation, please visit the detailed CPAN module installation guide.