Overview

Error::Pure system is replacement for usage of Perl die or Carp croak.

Main features are:

  • Structured and defined output

  • Stack trace support inside

Basic usage

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

Basic example