Try::Tiny::ByClass - selectively catch exceptions by class name
use Try::Tiny::ByClass; try { die $exception_object; } catch_case [ 'Some::Class' => sub { # handle Some::Class exceptions }, 'Exception::DivByZero' => sub { # handle Exception::DivByZero exceptions }, ], finally { # always do this };
This module is a simple wrapper around Try::Tiny, which see. It re-exports try, catch, and finally.
Try::Tiny
try
catch
finally
In addition, it provides a way to catch only some exceptions by filtering on the class (including superclasses and consumed roles) of an exception object.
Intended to be used instead of catch in the second argument position of try.
Instead of a block it takes a reference to an array of CLASS => CODEREF pairs, which it passes on to dispatch in Dispatch::Class.
CLASS => CODEREF
dispatch
Dispatch::Class
Try::Tiny, Dispatch::Class
Lukas Mai, <l.mai at web.de>
<l.mai at web.de>
Copyright 2013 Lukas Mai.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Try::Tiny::ByClass, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Try::Tiny::ByClass
CPAN shell
perl -MCPAN -e shell install Try::Tiny::ByClass
For more information on module installation, please visit the detailed CPAN module installation guide.