Try::Tiny::ByClass(3pm)

Try::Tiny::ByClass3pm

Selectively catch exceptions by class name

Usage

  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
  };

Overview

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".

Releases

6 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8–9
  2. 10
  3. 11
  4. 12
  5. 13

Author

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

From libtry-tiny-byclass-perl 0.01-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.