Error-Pure
view release on metacpan or search on metacpan
Error/Pure/Intent.pod view on Meta::CPAN
=pod
=encoding utf8
=head1 Overview
L<Error::Pure> system is replacement for usage of Perl C<die> or L<Carp> C<croak>.
Main features are:
=over
=item * Structured and defined output
=item * Stack trace support inside
=back
=head1 Basic usage
Simple Perl script, which have two subroutines and there is error inside.
Error output via L<Error::Pure> is to console and with ANSI colors.
Output formatter is placed in L<Error::Pure::Output::ANSIColor/err_bt_pretty>.
Environment set of output formatter
on bash
export ERROR_PURE_TYPE=ANSIColor::AllError
on tcsh
setenv ERROR_PURE_TYPE ANSIColor::AllError
Alternative way is add formatter to code
$Error::Pure::TYPE = 'ANSIColor::AllError';
Perl script
#!/usr/bin/env perl
use strict;
use warnings;
use Error::Pure qw(err);
sub first {
my $text = shift;
second($text);
return;
}
sub second {
my $text = shift;
err 'This is error',
'Context', $text,
;
}
first("Hello world");
Output to stderr
ERROR: This is error
Context: Hello world
main err /home/skim/data/gitprac/lang/perl/perl/MODULES/Error-Pure/ex19.pl 19
main second /home/skim/data/gitprac/lang/perl/perl/MODULES/Error-Pure/ex19.pl 11
main first /home/skim/data/gitprac/lang/perl/perl/MODULES/Error-Pure/ex19.pl 24
Output is in ANSI colors, you could look to image
=begin html
<a href="https://raw.githubusercontent.com/michal-josef-spacek/Error-Pure/master/images/basic_example.png">
<img src="https://raw.githubusercontent.com/michal-josef-spacek/Error-Pure/master/images/basic_example.png" alt="Basic example" width="300px" height="300px" />
</a>
=end html
=head1 Capture error
The sama example as previous with capturing of error and print all information
which we have. About fetching of information look to L<Error::Pure::Utils>.
Perl script
#!/usr/bin/env perl
use strict;
( run in 0.738 second using v1.01-cache-2.11-cpan-39bf76dae61 )