NAME
Venus::Throw - Throw Class
ABSTRACT
Throw Class for Perl 5
SYNOPSIS
package main;
use Venus::Throw;
my $throw = Venus::Throw->new;
# $throw->error;
DESCRIPTION
This package provides a mechanism for generating and raising errors (exception objects).
ATTRIBUTES
This package has the following attributes:
message
message(Str)
This attribute is read-write, accepts (Str)
values, and is optional.
package
package(Str)
This attribute is read-only, accepts (Str)
values, and is optional.
parent
parent(Str)
This attribute is read-only, accepts (Str)
values, is optional, and defaults to 'Venus::Error'
.
context
context(Str)
This attribute is read-only, accepts (Str)
values, and is optional.
INHERITS
This package inherits behaviors from:
INTEGRATES
This package integrates behaviors from:
METHODS
This package provides the following methods:
error
error(HashRef $data) (Error)
The error method throws the prepared error object.
Since 0.01
- error example 1
-
# given: synopsis; my $error = $throw->error; # bless({ # ..., # "context" => "(eval)", # "message" => "Exception!", # }, "Main::Error")
- error example 2
-
# given: synopsis; my $error = $throw->error({ message => 'Something failed!', context => 'Test.error', }); # bless({ # ..., # "context" => "Test.error", # "message" => "Something failed!", # }, "Main::Error")
- error example 3
-
package main; use Venus::Throw; my $throw = Venus::Throw->new('Example::Error'); my $error = $throw->error; # bless({ # ..., # "context" => "(eval)", # "message" => "Exception!", # }, "Example::Error")
- error example 4
-
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")
- error example 5
-
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")
AUTHORS
Cpanery, cpanery@cpan.org
LICENSE
Copyright (C) 2021, Cpanery
Read the "license" file.