NAME

Throwable::SugarFactory - build a library of syntax-sugared Throwable-based exceptions

VERSION

version 0.152070

SYNOPSIS

Declare exception clases in a library that will export sugar.

package My::SugarLib;
use Throwable::SugarFactory;

exception PlainError => "a generic error without metadata";
exception DataError  => "data description" =>
  has => [ flub => ( is => 'ro' ) ];

Use exception library to export sugar for exception object construction and class checking.

package My::Code;
use My::SugarLib;
use Try::Tiny;

try {
    die plain_error;
}
catch {
    die if !$_->isa( PlainError );
};

try {
    die data_error flub => 'blarb';
}
catch {
    die if !$_->isa( DataError );
    die if $_->flub ne 'blarb';
};

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at http://rt.cpan.org/Public/Dist/Display.html?Name=Throwable-SugarFactory. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/wchristian/Throwable-SugarFactory

git clone https://github.com/wchristian/Throwable-SugarFactory.git

AUTHOR

Christian Walde <walde.christian@gmail.com>

COPYRIGHT AND LICENSE

Christian Walde has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law.

Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author.