| 1 | package Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 33 | ▶ | use 5.018; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||
| 5 | 33 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 6 | 33 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | # IMPORTS | ||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | 33 | ▶ | use Venus::Class 'attr', 'base'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | # INHERITS | ||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 32 | base 'Venus::Error'; | |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | # OVERLOADS | ||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 32 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||
| 19 | 14 | ▶ | '""' => sub{$_[0]->error->explain}, | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | '~~' => sub{$_[0]->error->explain}, | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 21 | 32 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 32 | ); | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | # ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 32 | attr 'package'; | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 32 | attr 'parent'; | |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | # BUILDERS | ||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 20 | ▶ | sub build_arg { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_arg: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 20 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | return { | ||||||||||||||||||||||||||||||||||||||||||||
| 35 | 20 | package => $data, | |||||||||||||||||||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 517 | ▶ | sub build_self { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_self: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 517 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 517 | ▶ | if (!$self->parent) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 43 | 494 | $self->parent('Venus::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 517 | ▶ | if (my $stash = delete $data->{stash}) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | %{$self->stash} = %{$stash}; | |||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 517 | return $self; | |||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | # METHODS | ||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 212 | ▶ | sub die { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
die: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 212 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 212 | ▶ | $data ||= {}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$data ||= {}
MC/DC100%1/1
$data ||= {}
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 212 | $data->{raise} = true; | |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 212 | @_ = ($self, $data); | |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 212 | goto $self->can('error'); | |||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | 507 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=18 SCAR=31.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 507 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 507 | ▶ | $data ||= {}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$data ||= {}
MC/DC100%1/1
$data ||= {}
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 507 | for my $key (keys %{$data}) { | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 462 | ▶ | next if $key eq 'die'; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 462 | ▶ | next if $key eq 'error'; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 462 | ▶ | $self->$key($data->{$key}) if $self->can($key); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 507 | my $context = $self->context; | |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 507 | ▶ | if (!$context) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 82 | 22 | ▶ | $context = $self->context((caller(($self->offset // 0) + 1))[3]); | ||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->offset // 0
MC/DC0%0/1
$self->offset // 0
$self->offset
Truth table50%1/2
A
A= $self->offset
| |||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 507 | my $package = $self->package; | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 507 | ▶ | if (!$package) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 187 | ▶ | $package = $self->package(join('::', map ucfirst, (caller($self->offset // 0))[0], 'error')); | ||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->offset // 0
MC/DC0%0/1
$self->offset // 0
$self->offset
Truth table50%1/2
A
A= $self->offset
| |||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 507 | my $parent = $self->parent; | |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | 507 | ▶ | if (!$parent) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $parent = $self->parent('Venus::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | 507 | local $@; | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 31 | ▶ | if (!$package->can('new') and !eval "package $package; use base '$parent'; 1") { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
$package->can("new") or eval "package $package; use base '${parent}'; 1"
MC/DC100%2/2
$package->can("new") or eval "package $package; use base '${parent}'; 1"
$package->can("new")
eval "package $package; use base '${parent}'; 1"
Truth table100%3/3
A or B
A= $package->can("new")B= eval "package $package; use base '${parent}'; 1"
| |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | my $throw = $self->class->new; | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | $throw->message($@); | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | $throw->package('Venus::Throw::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | $throw->parent('Venus::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | $throw->stash(package => $package); | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | $throw->stash(parent => $parent); | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | $throw->die; | |||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 505 | ▶ | if (!$parent->isa('Venus::Error')) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $throw = $self->class->new; | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $throw->message(qq(Parent '$parent' doesn't derive from 'Venus::Error')); | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $throw->package('Venus::Throw::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $throw->parent('Venus::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $throw->stash(package => $package); | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $throw->stash(parent => $parent); | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $throw->die; | |||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 505 | ▶ | if (!$package->isa('Venus::Error')) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $throw = $self->class->new; | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $throw->message(qq(Package '$package' doesn't derive from 'Venus::Error')); | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $throw->package('Venus::Throw::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $throw->parent('Venus::Error'); | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $throw->stash(package => $package); | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $throw->stash(parent => $parent); | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $throw->die; | |||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 505 | my $error = $package->new->copy($self); | |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 505 | ▶ | (@_ = ($error)) && goto $error->can('throw') if $data && $data->{raise}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition71%5/7
$data && $data->{'raise'} && ((@_ = $error) && (goto $error->can('throw')))
$data and $data->{"raise"}
@_ = $error and goto $error->can("throw")
MC/DC0%0/3
$data && $data->{'raise'} && ((@_ = $error) && (goto $error->can('throw')))
$data
$data->{"raise"}
@_ = $error
Truth table25%1/4
A and B && C
A= $dataB= $data->{"raise"}C= @_ = $error
| |||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 293 | return $error; | |||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 32 | 1; | |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | Venus::Throw - Throw Class | ||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | =head1 ABSTRACT | ||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | Throw Class for Perl 5 | ||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | my $throw = Venus::Throw->new; | ||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | # $throw->error; | ||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | This package provides a mechanism for generating and raising errors (exception | ||||||||||||||||||||||||||||||||||||||||||||
| 167 | objects). | ||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | This package has the following attributes: | ||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | =head2 package | ||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | package(string $package) (string) | ||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | The package attribute is read-write, accepts C<(string)> values, and is | ||||||||||||||||||||||||||||||||||||||||||||
| 182 | optional. | ||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | =item package example 1 | ||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | my $package = $throw->package("Example"); | ||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | # "Example" | ||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | =item package example 2 | ||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | # given: example-1 package | ||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | $package = $throw->package; | ||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | # "Example" | ||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | =head2 parent | ||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | parent(string $parent) (string) | ||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | The parent attribute is read-write, accepts C<(string)> values, and is | ||||||||||||||||||||||||||||||||||||||||||||
| 223 | optional. | ||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | =item parent example 1 | ||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | my $parent = $throw->parent("Venus::Error"); | ||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | # "Venus::Error" | ||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | =item parent example 2 | ||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | # given: example-1 parent | ||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | $parent = $throw->parent; | ||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | # "Venus::Error" | ||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | =head1 INHERITS | ||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | This package inherits behaviors from: | ||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | L<Venus::Error> | ||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | This package provides the following methods: | ||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | =head2 die | ||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | die(hashref $data) (Venus::Error) | ||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | The die method builds an error object from the attributes set on the invocant | ||||||||||||||||||||||||||||||||||||||||||||
| 278 | and throws it. | ||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | =item die example 1 | ||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | my $die = $throw->die; | ||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 291 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 292 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 293 | # "message" => "Exception!", | ||||||||||||||||||||||||||||||||||||||||||||
| 294 | # }, "Main::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | =item die example 2 | ||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | my $die = $throw->die({ | ||||||||||||||||||||||||||||||||||||||||||||
| 305 | message => 'Something failed!', | ||||||||||||||||||||||||||||||||||||||||||||
| 306 | context => 'Test.error', | ||||||||||||||||||||||||||||||||||||||||||||
| 307 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 310 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 311 | # "context" => "Test.error", | ||||||||||||||||||||||||||||||||||||||||||||
| 312 | # "message" => "Something failed!", | ||||||||||||||||||||||||||||||||||||||||||||
| 313 | # }, "Main::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | =item die example 3 | ||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | my $throw = Venus::Throw->new('Example::Error'); | ||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | my $die = $throw->die; | ||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||
| 329 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 330 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 331 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 332 | # "message" => "Exception!", | ||||||||||||||||||||||||||||||||||||||||||||
| 333 | # }, "Example::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||
| 337 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | =item die example 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||
| 341 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | my $throw = Venus::Throw->new( | ||||||||||||||||||||||||||||||||||||||||||||
| 346 | package => 'Example::Error', | ||||||||||||||||||||||||||||||||||||||||||||
| 347 | parent => 'Venus::Error', | ||||||||||||||||||||||||||||||||||||||||||||
| 348 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | my $die = $throw->die({ | ||||||||||||||||||||||||||||||||||||||||||||
| 351 | message => 'Example error!', | ||||||||||||||||||||||||||||||||||||||||||||
| 352 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 355 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 356 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 357 | # "message" => "Example error!", | ||||||||||||||||||||||||||||||||||||||||||||
| 358 | # }, "Example::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||
| 360 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | =item die example 5 | ||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | package Example::Error; | ||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | use base 'Venus::Error'; | ||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | my $throw = Venus::Throw->new( | ||||||||||||||||||||||||||||||||||||||||||||
| 375 | package => 'Example::Error::Unknown', | ||||||||||||||||||||||||||||||||||||||||||||
| 376 | parent => 'Example::Error', | ||||||||||||||||||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | my $die = $throw->die({ | ||||||||||||||||||||||||||||||||||||||||||||
| 380 | message => 'Example error (unknown)!', | ||||||||||||||||||||||||||||||||||||||||||||
| 381 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||
| 383 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 384 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 385 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 386 | # "message" => "Example error (unknown)!", | ||||||||||||||||||||||||||||||||||||||||||||
| 387 | # }, "Example::Error::Unknown") | ||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | =item die example 6 | ||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||
| 397 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||
| 399 | my $throw = Venus::Throw->new( | ||||||||||||||||||||||||||||||||||||||||||||
| 400 | package => 'Example::Error::NoThing', | ||||||||||||||||||||||||||||||||||||||||||||
| 401 | parent => 'No::Thing', | ||||||||||||||||||||||||||||||||||||||||||||
| 402 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | my $die = $throw->die({ | ||||||||||||||||||||||||||||||||||||||||||||
| 405 | message => 'Example error (no thing)!', | ||||||||||||||||||||||||||||||||||||||||||||
| 406 | raise => true, | ||||||||||||||||||||||||||||||||||||||||||||
| 407 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | # No::Thing does not exist | ||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | # Exception! Venus::Throw::Error (isa Venus::Error) | ||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | =item die example 7 | ||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||
| 421 | my $die = $throw->die({ | ||||||||||||||||||||||||||||||||||||||||||||
| 422 | name => 'on.test.error', | ||||||||||||||||||||||||||||||||||||||||||||
| 423 | context => 'Test.error', | ||||||||||||||||||||||||||||||||||||||||||||
| 424 | message => 'Something failed!', | ||||||||||||||||||||||||||||||||||||||||||||
| 425 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 428 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 429 | # "context" => "Test.error", | ||||||||||||||||||||||||||||||||||||||||||||
| 430 | # "message" => "Something failed!", | ||||||||||||||||||||||||||||||||||||||||||||
| 431 | # "name" => "on_test_error", | ||||||||||||||||||||||||||||||||||||||||||||
| 432 | # }, "Main::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | =head2 error | ||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | error(hashref $data) (Venus::Error) | ||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | The error method builds an error object from the attributes set on the invocant | ||||||||||||||||||||||||||||||||||||||||||||
| 443 | and returns or optionally automatically throws it. | ||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||
| 445 | I<Since C<0.01>> | ||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | =item error example 1 | ||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | my $error = $throw->error; | ||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||
| 455 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 456 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 457 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 458 | # "message" => "Exception!", | ||||||||||||||||||||||||||||||||||||||||||||
| 459 | # }, "Main::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||
| 461 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||
| 463 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||
| 465 | =item error example 2 | ||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||
| 469 | my $error = $throw->error({ | ||||||||||||||||||||||||||||||||||||||||||||
| 470 | message => 'Something failed!', | ||||||||||||||||||||||||||||||||||||||||||||
| 471 | context => 'Test.error', | ||||||||||||||||||||||||||||||||||||||||||||
| 472 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||
| 474 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 475 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 476 | # "context" => "Test.error", | ||||||||||||||||||||||||||||||||||||||||||||
| 477 | # "message" => "Something failed!", | ||||||||||||||||||||||||||||||||||||||||||||
| 478 | # }, "Main::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||
| 480 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||
| 484 | =item error example 3 | ||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | my $throw = Venus::Throw->new('Example::Error'); | ||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||
| 492 | my $error = $throw->error; | ||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 495 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 496 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 497 | # "message" => "Exception!", | ||||||||||||||||||||||||||||||||||||||||||||
| 498 | # }, "Example::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||
| 500 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||
| 502 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | =item error example 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||
| 508 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||
| 510 | my $throw = Venus::Throw->new( | ||||||||||||||||||||||||||||||||||||||||||||
| 511 | package => 'Example::Error', | ||||||||||||||||||||||||||||||||||||||||||||
| 512 | parent => 'Venus::Error', | ||||||||||||||||||||||||||||||||||||||||||||
| 513 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||
| 515 | my $error = $throw->error({ | ||||||||||||||||||||||||||||||||||||||||||||
| 516 | message => 'Example error!', | ||||||||||||||||||||||||||||||||||||||||||||
| 517 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||
| 519 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 520 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 521 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 522 | # "message" => "Example error!", | ||||||||||||||||||||||||||||||||||||||||||||
| 523 | # }, "Example::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||
| 527 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | =item error example 5 | ||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||
| 531 | package Example::Error; | ||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||
| 533 | use base 'Venus::Error'; | ||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||
| 537 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||
| 539 | my $throw = Venus::Throw->new( | ||||||||||||||||||||||||||||||||||||||||||||
| 540 | package => 'Example::Error::Unknown', | ||||||||||||||||||||||||||||||||||||||||||||
| 541 | parent => 'Example::Error', | ||||||||||||||||||||||||||||||||||||||||||||
| 542 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||
| 544 | my $error = $throw->error({ | ||||||||||||||||||||||||||||||||||||||||||||
| 545 | message => 'Example error (unknown)!', | ||||||||||||||||||||||||||||||||||||||||||||
| 546 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||
| 548 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 549 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 550 | # "context" => "(eval)", | ||||||||||||||||||||||||||||||||||||||||||||
| 551 | # "message" => "Example error (unknown)!", | ||||||||||||||||||||||||||||||||||||||||||||
| 552 | # }, "Example::Error::Unknown") | ||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||
| 554 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||
| 556 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||
| 558 | =item error example 6 | ||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||
| 560 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||
| 562 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||
| 564 | my $throw = Venus::Throw->new( | ||||||||||||||||||||||||||||||||||||||||||||
| 565 | package => 'Example::Error::NoThing', | ||||||||||||||||||||||||||||||||||||||||||||
| 566 | parent => 'No::Thing', | ||||||||||||||||||||||||||||||||||||||||||||
| 567 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||
| 569 | my $error = $throw->error({ | ||||||||||||||||||||||||||||||||||||||||||||
| 570 | message => 'Example error (no thing)!', | ||||||||||||||||||||||||||||||||||||||||||||
| 571 | raise => true, | ||||||||||||||||||||||||||||||||||||||||||||
| 572 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | # No::Thing does not exist | ||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | # Exception! Venus::Throw::Error (isa Venus::Error) | ||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||
| 578 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||
| 580 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | =item error example 7 | ||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||
| 584 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | my $error = $throw->error({ | ||||||||||||||||||||||||||||||||||||||||||||
| 587 | name => 'on.test.error', | ||||||||||||||||||||||||||||||||||||||||||||
| 588 | context => 'Test.error', | ||||||||||||||||||||||||||||||||||||||||||||
| 589 | message => 'Something failed!', | ||||||||||||||||||||||||||||||||||||||||||||
| 590 | }); | ||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | # bless({ | ||||||||||||||||||||||||||||||||||||||||||||
| 593 | # ..., | ||||||||||||||||||||||||||||||||||||||||||||
| 594 | # "context" => "Test.error", | ||||||||||||||||||||||||||||||||||||||||||||
| 595 | # "message" => "Something failed!", | ||||||||||||||||||||||||||||||||||||||||||||
| 596 | # "name" => "on_test_error", | ||||||||||||||||||||||||||||||||||||||||||||
| 597 | # }, "Main::Error") | ||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||
| 599 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||
| 601 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||
| 603 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||
| 605 | new(any @args) (Venus::Throw) | ||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||
| 607 | The new method constructs an instance of the package. | ||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||
| 609 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||
| 613 | =item new example 1 | ||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||
| 615 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||
| 617 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||
| 619 | my $new = Venus::Throw->new; | ||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||
| 621 | # bless(..., "Venus::Throw") | ||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||
| 623 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||
| 625 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||
| 627 | =item new example 2 | ||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||
| 629 | package main; | ||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||
| 631 | use Venus::Throw; | ||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||
| 633 | my $new = Venus::Throw->new(package => 'Example::Error', parent => 'Venus::Error'); | ||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||
| 635 | # bless(..., "Venus::Throw") | ||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||
| 637 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||
| 639 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||
| 641 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||
| 645 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||
| 647 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||
| 649 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||
| 651 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||
| 652 | the terms of the Apache license version 2.0. | ||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||
| 654 | =cut | ||||||||||||||||||||||||||||||||||||||||||||