Error::Pure system is replacement for usage of Perl die or Carp croak.
die
croak
Main features are:
Structured and defined output
Stack trace support inside
Simple Perl script, which have two subroutines and there is error inside. Error output via Error::Pure is to console and with ANSI colors. Output formatter is placed in "err_bt_pretty" in Error::Pure::Output::ANSIColor.
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("Hellow world");
Output to stderr
ERROR: This is error Context: Hellow 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
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.