logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Try::Tiny::ByClass - selectively catch exceptions by class name

Author

       Lukas Mai, "<l.mai at web.de>"

Description

       This module is a simple wrapper around "Try::Tiny", which see. It re-exports "try", "catch", and
       "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.

   Functions
       catch_case ($;@)
           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".

Name

       Try::Tiny::ByClass - selectively catch exceptions by class name

See Also

       Try::Tiny, Dispatch::Class

Synopsis

         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 Also