NAME
Error::Pure::Utils - Utilities for structured errors.
SYNOPSIS
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'
);
SUBROUTINES
clean
clean();
Resets internal variables with errors. It is exportable.
Returns undef.
err_get
my
@errors
= 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
my
@err_msg
= 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
my
$err_msg_hr
= 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
my
@errors
= err_helper(
'This is a fatal error'
,
'name'
,
'value'
);
Subroutine for additional module above Error::Pure. @msg is array of messages. If last error is undef, rewrite it to 'undef' string. If @msg is blank, add 'undef' string. Chomp last error. It is exportable.
Returns array of errors.
VARIABLES
$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
-
Default value is 50.
$PROGRAM
-
Program name in stack information.
Default value is
''
.
EXAMPLE1
use
strict;
use
warnings;
use
Dumpvalue;
# 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 {...}',
# },
# ],
# },
# ],
EXAMPLE2
EXAMPLE3
DEPENDENCIES
SEE ALSO
- Task::Error::Pure
-
Install the Error::Pure modules.
REPOSITORY
https://github.com/michal-josef-spacek/Error-Pure
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2008-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.34