Try::T...yClass(3pm)
π Try::Tiny::ByClass β the perl manual, but make it cute β¨
okay bestie, gather round, because this is a User Contributed Perl Documentation page for a module called Try::Tiny::ByClass, and it is lowkey iconic π
πΈ NAME πΈ
Try::Tiny::ByClass β catch exceptions selectively, by class name π
like, not every exception deserves your attention, yk? this one lets you pick and choose π¦
β¨ SYNOPSIS β¨
here's the whole vibe, verbatim, no cap:
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
};
see how it's giving organized? that's the whole point π«Ά
π DESCRIPTION π
okay so. this module is a simple wrapper around Try::Tiny, which see π (fr fr, go read that one too). It re-exports try, catch, and finally β so you get all the classics, bestie π
and on top of that, it gives you a way to catch only some exceptions, by filtering on the class of an exception object. and when we say class we mean it in the full sense: superclasses and consumed roles count too, so your subclass energy is very much recognized π
π§ Functions π§
catch_case ($;@)
this one is intended to be used instead of catch β specifically in the second argument position</u> of try π
instead of taking a block like catch does, it takes a reference to an array of CLASS => CODEREF pairs π« and then it passes that whole thing on to dispatch in Dispatch::Class.
so yeah, it's basically a lil matchmaker between your exceptions and your handlers. slay π
π SEE ALSO π
Try::TinyDispatch::Class
go read them, iykyk πβ¨
π AUTHOR π
Lukas Mai, <l.mai at web.de> π
(genuinely the author, we're just being grateful π«Ά)
π COPYRIGHT & LICENSE π
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.
no fr, go read the licenses, they're not a vibe you can just skip π
and that's the whole page, bestie π
this beauty shipped with perl v5.36.0 and it was dated 2022-11-21, so if you're citing it in your essayβ¦ there's your receipt π§Ύβ¨
periodt. π πΈπ¦
π¦ where this page comes from
- debian bookworm: libtry-tiny-byclass-perl 0.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtry-tiny-byclass-perl 0.01-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms