Venus::Role::Catchable

Catchable Role

Catchable Role for Perl 5

method: catch

package Example;

use Venus::Class;

use Venus 'error';

with 'Venus::Role::Tryable';
with 'Venus::Role::Catchable';

sub pass {
  true;
}

sub fail {
  error;
}

package main;

my $example = Example->new;

# my $error = $example->catch('fail');

This package modifies the consuming package and provides methods for trapping errors thrown from dispatched method calls.

The catch method traps any errors raised by executing the dispatched method call and returns the error string or error object. This method can return a list of values in list-context. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.

catch(Str $method, Any @args) (Any)

{ since => '0.01', }

=example-1 catch

package main;

my $example = Example->new;

my $catch = $example->catch('fail');

# bless({...}, "Venus::Error")

t/Venus.t: pdml: authors t/Venus.t: pdml: license

13 POD Errors

The following errors were encountered while parsing the POD:

Around line 13:

Unknown directive: =name

Around line 21:

Unknown directive: =tagline

Around line 29:

Unknown directive: =abstract

Around line 37:

Unknown directive: =includes

Around line 45:

Unknown directive: =synopsis

Around line 81:

Unknown directive: =description

Around line 90:

Unknown directive: =method

Around line 98:

Unknown directive: =signature

Around line 102:

Unknown directive: =metadata

Around line 138:

=cut found outside a pod block. Skipping to next block.

Around line 158:

=cut found outside a pod block. Skipping to next block.

Around line 179:

=cut found outside a pod block. Skipping to next block.

Around line 190:

Unknown directive: =partials