Venus::Throw - Throw Class
Throw Class for Perl 5
package main; use Venus::Throw; my $throw = Venus::Throw->new; # $throw->error;
This package provides a mechanism for generating and raising errors (exception objects).
This package has the following attributes:
name(Str)
This attribute is read-write, accepts (Str) values, and is optional.
(Str)
message(Str)
package(Str)
This attribute is read-only, accepts (Str) values, and is optional.
parent(Str)
This attribute is read-only, accepts (Str) values, is optional, and defaults to 'Venus::Error'.
'Venus::Error'
context(Str)
This package inherits behaviors from:
Venus::Kind::Utility
This package integrates behaviors from:
Venus::Role::Stashable
This package provides the following methods:
error(HashRef $data) (Error)
The error method throws the prepared error object.
Since 0.01
0.01
# given: synopsis; my $error = $throw->error; # bless({ # ..., # "context" => "(eval)", # "message" => "Exception!", # }, "Main::Error")
# given: synopsis; my $error = $throw->error({ message => 'Something failed!', context => 'Test.error', }); # bless({ # ..., # "context" => "Test.error", # "message" => "Something failed!", # }, "Main::Error")
package main; use Venus::Throw; my $throw = Venus::Throw->new('Example::Error'); my $error = $throw->error; # bless({ # ..., # "context" => "(eval)", # "message" => "Exception!", # }, "Example::Error")
package main; use Venus::Throw; my $throw = Venus::Throw->new( package => 'Example::Error', parent => 'Venus::Error', ); my $error = $throw->error({ message => 'Example error!', }); # bless({ # ..., # "context" => "(eval)", # "message" => "Example error!", # }, "Example::Error")
package Example::Error; use base 'Venus::Error'; package main; use Venus::Throw; my $throw = Venus::Throw->new( package => 'Example::Error::Unknown', parent => 'Example::Error', ); my $error = $throw->error({ message => 'Example error (unknown)!', }); # bless({ # ..., # "context" => "(eval)", # "message" => "Example error (unknown)!", # }, "Example::Error::Unknown")
package main; use Venus::Throw; my $throw = Venus::Throw->new( package => 'Example::Error::NoThing', parent => 'No::Thing', ); my $error = $throw->error({ message => 'Example error (no thing)!', }); # No::Thing does not exist # Exception! Venus::Throw::Error (isa Venus::Error)
# given: synopsis; my $error = $throw->error({ name => 'on.test.error', context => 'Test.error', message => 'Something failed!', }); # bless({ # ..., # "context" => "Test.error", # "message" => "Something failed!", # "name" => "on_test_error", # }, "Main::Error")
To install Venus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Venus
CPAN shell
perl -MCPAN -e shell install Venus
For more information on module installation, please visit the detailed CPAN module installation guide.