line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Throwable::SugarFactory; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
80811
|
use strictures 2; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
907
|
use Import::Into; |
|
1
|
|
|
|
|
439
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
526
|
use MooX::SugarFactory (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
4
|
use Throwable::SugarFactory::Utils '_getglob'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
7
|
1
|
|
|
1
|
|
4
|
use Throwable (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
190
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.152690'; # 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
|
|
4
|
my ( $namespace, $error, $description ) = @_; |
29
|
|
|
|
|
|
|
return ( |
30
|
3
|
|
|
|
|
30
|
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
|
|
15
|
MooX::SugarFactory->import::into( 1 ); |
39
|
1
|
|
|
|
|
6
|
my $factory = caller; |
40
|
1
|
|
|
|
|
2
|
*{ _getglob $factory, "exception" } = sub { |
41
|
3
|
|
|
3
|
|
17
|
my ( $id, $description, @args ) = @_; |
42
|
3
|
|
|
|
|
6
|
my $class = "${factory}::$id"; |
43
|
3
|
|
|
|
|
7
|
$factory->can( "class" )->( |
44
|
|
|
|
|
|
|
"$class->throw", _base_args( $factory, $id, $description ), @args |
45
|
|
|
|
|
|
|
); |
46
|
1
|
|
|
|
|
5
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |