use Error::Tiny; try { dangerous(); } catch MyCustomException then { my $e = shift; ...everything whose parent is MyCustomException... } catch { my $e = shift; ...everything else goes here... };
try { dangerous(); } catch { my $e = $_; if (blessed($e) && $e->isa('MyCustomException')) { } else { } };
To install Error::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Error::Tiny
CPAN shell
perl -MCPAN -e shell install Error::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.