line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Throwable::SugarFactory; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
133539
|
use strictures 2; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
672
|
use Import::Into; |
|
1
|
|
|
|
|
512
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
423
|
use MooX::SugarFactory (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
7
|
use Throwable::SugarFactory::Utils '_getglob'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
7
|
1
|
|
|
1
|
|
5
|
use Throwable (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
213
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.213360'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: build a library of syntax-sugared Throwable-based exceptions |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# This file is part of Throwable-SugarFactory |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# Christian Walde has dedicated the work to the Commons by waiving all of his |
18
|
|
|
|
|
|
|
# or her rights to the work worldwide under copyright law and all related or |
19
|
|
|
|
|
|
|
# neighboring legal rights he or she had in the work, to the extent allowable by |
20
|
|
|
|
|
|
|
# law. |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
# Works under CC0 do not require attribution. When citing the work, you should |
23
|
|
|
|
|
|
|
# not imply endorsement by the author. |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _base_args { |
28
|
3
|
|
|
3
|
|
8
|
my ( $namespace, $error, $description ) = @_; |
29
|
|
|
|
|
|
|
return ( |
30
|
3
|
|
|
|
|
29
|
with => [ "Throwable", __PACKAGE__ . "::Hashable" ], |
31
|
|
|
|
|
|
|
has => [ namespace => ( is => 'ro', default => $namespace ) ], |
32
|
|
|
|
|
|
|
has => [ error => ( is => 'ro', default => $error ) ], |
33
|
|
|
|
|
|
|
has => [ description => ( is => 'ro', default => $description ) ], |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub import { |
38
|
1
|
|
|
1
|
|
14
|
MooX::SugarFactory->import::into( scalar caller ); # I::I 1.001000 syntax |
39
|
1
|
|
|
|
|
8
|
my $factory = caller; |
40
|
1
|
|
|
|
|
9
|
*{ _getglob $factory, "exception" } = sub { |
41
|
3
|
|
|
3
|
|
20
|
my ( $id, $description, @args ) = @_; |
42
|
3
|
|
|
|
|
9
|
my $class = "${factory}::$id"; |
43
|
3
|
|
|
|
|
7
|
$factory->can( "class" )->( |
44
|
|
|
|
|
|
|
"$class->throw", _base_args( $factory, $id, $description ), @args |
45
|
|
|
|
|
|
|
); |
46
|
1
|
|
|
|
|
3
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |