NAME
Error::Pure::Output::Text - Output subroutines for Error::Pure.
SYNOPSIS
use Error::Pure::Output::Text qw(err_bt_pretty err_line err_line_all);
print err_bt_pretty(@errors);
print err_line_all(@errors);
print err_line(@errors);
SUBROUTINES
err_bt_pretty(@errors)
-
Returns string with full backtrace in scalar context. Returns array of full backtrace lines in array context. Format of error is: ERROR: %s %s: %s ... %s %s %s %s ... Values of error are: message message as key, $message as value ... sub, caller, program, line
err_line_all(@errors)
-
Returns string with errors each on one line. Use all errors in @errors structure. Format of error line is: "#Error [%s:%s] %s\n" Values of error line are: $program, $line, $message
err_line(@errors)
-
Returns string with error on one line. Use last error in @errors structure.. Format of error is: "#Error [%s:%s] %s\n" Values of error are: $program, $line, $message
ERRORS
None.
EXAMPLE1
# Pragmas.
use strict;
use warnings;
# Modules.
use Error::Pure::Output::Text qw(err_bt_pretty);
# Fictional error structure.
my $err_hr = {
'msg' => [
'FOO',
'KEY',
'VALUE',
],
'stack' => [
{
'args' => '(2)',
'class' => 'main',
'line' => 1,
'prog' => 'script.pl',
'sub' => 'err',
}, {
'args' => '',
'class' => 'main',
'line' => 20,
'prog' => 'script.pl',
'sub' => 'eval {...}',
}
],
};
# Print out.
print scalar err_bt_pretty($err_hr);
# Output:
# ERROR: FOO
# KEY: VALUE
# main err script.pl 1
# main eval {...} script.pl 20
EXAMPLE2
# Pragmas.
use strict;
use warnings;
# Modules.
use Error::Pure::Output::Text qw(err_line_all);
# Fictional error structure.
my @err = (
{
'msg' => [
'FOO',
'BAR',
],
'stack' => [
{
'args' => '(2)',
'class' => 'main',
'line' => 1,
'prog' => 'script.pl',
'sub' => 'err',
}, {
'args' => '',
'class' => 'main',
'line' => 20,
'prog' => 'script.pl',
'sub' => 'eval {...}',
}
],
}, {
'msg' => ['XXX'],
'stack' => [
{
'args' => '',
'class' => 'main',
'line' => 2,
'prog' => 'script.pl',
'sub' => 'err',
},
],
}
);
# Print out.
print err_line_all(@err);
# Output:
# #Error [script.pl:1] FOO
# #Error [script.pl:2] XXX
EXAMPLE3
# Pragmas.
use strict;
use warnings;
# Modules.
use Error::Pure::Output::Text qw(err_line);
# Fictional error structure.
my $err_hr = {
'msg' => [
'FOO',
'BAR',
],
'stack' => [
{
'args' => '(2)',
'class' => 'main',
'line' => 1,
'prog' => 'script.pl',
'sub' => 'err',
}, {
'args' => '',
'class' => 'main',
'line' => 20,
'prog' => 'script.pl',
'sub' => 'eval {...}',
}
],
};
# Print out.
print err_line($err_hr);
# Output:
# #Error [script.pl:1] FOO
DEPENDENCIES
SEE ALSO
Error::Pure, Error::Pure::AllError, Error::Pure::Die, Error::Pure::Error, Error::Pure::ErrorList, Error::Pure::Print, Error::Pure::Utils,
REPOSITORY
https://github.com/tupinek/Error-Pure
AUTHOR
Michal Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
BSD 2-Clause License
VERSION
0.17