Venus::Error - Error Class
Error Class for Perl 5
package main; use Venus::Error; my $error = Venus::Error->new; # $error->throw;
This package represents a context-aware error (exception object).
This package has the following attributes:
context(Str)
This attribute is read-write, accepts (Str) values, is optional, and defaults to '(None)'.
(Str)
'(None)'
message(Str)
This attribute is read-write, accepts (Str) values, is optional, and defaults to 'Exception!'.
'Exception!'
This package inherits behaviors from:
Venus::Kind::Utility
This package integrates behaviors from:
Venus::Role::Explainable
Venus::Role::Stashable
This package provides the following methods:
explain() (Str)
The explain method returns the error message and is used in stringification operations.
Since 0.01
0.01
# given: synopsis; my $explain = $error->explain; # "Exception! in ...
frames() (ArrayRef)
The frames method returns the compiled and stashed stack trace data.
# given: synopsis; my $frames = $error->frames; # [ # ... # [ # "main", # "t/Venus_Error.t", # ... # ], # ]
throw(Any @data) (Error)
The throw method throws an error if the invocant is an object, or creates an error object using the arguments provided and throws the created object.
# given: synopsis; my $throw = $error->throw; # bless({ ... }, 'Venus::Error')
trace(Int $offset, Int $limit) (Error)
The trace method compiles a stack trace and returns the object. By default it skips the first frame.
# given: synopsis; my $trace = $error->trace; # bless({ ... }, 'Venus::Error')
# given: synopsis; my $trace = $error->trace(0, 1); # bless({ ... }, 'Venus::Error')
# given: synopsis; my $trace = $error->trace(0, 2); # bless({ ... }, 'Venus::Error')
This package overloads the following operators:
(.)
This package overloads the . operator.
.
example 1
# given: synopsis; my $string = $error . ' Unknown'; # "Exception! Unknown"
(eq)
This package overloads the eq operator.
eq
# given: synopsis; my $result = $error eq 'Exception!'; # 1
(ne)
This package overloads the ne operator.
ne
# given: synopsis; my $result = $error ne 'exception!'; # 1
(qr)
This package overloads the qr operator.
qr
# given: synopsis; my $test = 'Exception!' =~ qr/$error/; # 1
Cpanery, cpanery@cpan.org
cpanery@cpan.org
Copyright (C) 2021, Cpanery
Read the "license" file.
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.