Venus::Role::Throwable
Throwable Role
Throwable Role for Perl 5
method: error method: throw
package Example;
use Venus::Class;
with 'Venus::Role::Throwable';
package main;
my $example = Example->new;
# $example->throw;
This package modifies the consuming package and provides a mechanism for throwing context-aware errors (exceptions).
The error method dispatches to the "throw" method, excepts a hashref of options to be provided to the "throw" method, and returns the result unless an exception is raised automatically. If the throw option is provided it is excepted to be the name of a method used as a callback to provide arguments to the thrower.
error(hashref $data) (any)
{ since => '3.40', }
The throw method builds a Venus::Throw object, which can raise errors (exceptions). If passed a string representing a package name, the throw object will be configured to throw an exception using that package name. If passed a string representing a method name, the throw object will call that method expecting a hashref to be returned which will be provided to Venus::Throw as arguments to configure the thrower. If passed a hashref, the keys and values are expected to be method names and arguments which will be called to configure the Venus::Throw object returned. If passed additional arguments, assuming they are preceeded by a string representing a method name, the additional arguments will be supplied to the method when called. If the raise argument is provided (or returned from the callback), the thrower will automatically throw the exception.
throw(maybe[string | hashref] $data, any @args) (any)
{ since => '0.01', }
=example-1 throw
package main;
my $example = Example->new;
my $throw = $example->throw;
# bless({ "package" => "Example::Error", ..., }, "Venus::Throw")
# $throw->error;
t/Venus.t: present: authors t/Venus.t: present: license
22 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 46:
Unknown directive: =synopsis
- Around line 71:
Unknown directive: =description
- Around line 80:
Unknown directive: =method
- Around line 88:
Unknown directive: =signature
- Around line 92:
Unknown directive: =metadata
- Around line 112:
=cut found outside a pod block. Skipping to next block.
- Around line 135:
=cut found outside a pod block. Skipping to next block.
- Around line 164:
=cut found outside a pod block. Skipping to next block.
- Around line 206:
=cut found outside a pod block. Skipping to next block.
- Around line 247:
=cut found outside a pod block. Skipping to next block.
- Around line 259:
Unknown directive: =method
- Around line 274:
Unknown directive: =signature
- Around line 278:
Unknown directive: =metadata
- Around line 319:
=cut found outside a pod block. Skipping to next block.
- Around line 348:
=cut found outside a pod block. Skipping to next block.
- Around line 390:
=cut found outside a pod block. Skipping to next block.
- Around line 431:
=cut found outside a pod block. Skipping to next block.
- Around line 443:
Unknown directive: =partials