| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Error::TypeTiny; |
|
2
|
|
|
|
|
|
|
|
|
3
|
268
|
|
|
268
|
|
7925
|
use 5.008001; |
|
|
268
|
|
|
|
|
996
|
|
|
4
|
268
|
|
|
268
|
|
1448
|
use strict; |
|
|
268
|
|
|
|
|
508
|
|
|
|
268
|
|
|
|
|
5823
|
|
|
5
|
268
|
|
|
268
|
|
2247
|
use warnings; |
|
|
268
|
|
|
|
|
631
|
|
|
|
268
|
|
|
|
|
12047
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
|
8
|
268
|
|
|
268
|
|
986
|
$Error::TypeTiny::AUTHORITY = 'cpan:TOBYINK'; |
|
9
|
268
|
|
|
|
|
226846
|
$Error::TypeTiny::VERSION = '2.004000'; |
|
10
|
|
|
|
|
|
|
} |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$Error::TypeTiny::VERSION =~ tr/_//d; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Type::Tiny; |
|
15
|
|
|
|
|
|
|
__PACKAGE__->Type::Tiny::_install_overloads( |
|
16
|
737
|
|
|
737
|
|
225012
|
q[""] => sub { $_[0]->to_string }, |
|
17
|
1628
|
|
|
1628
|
|
11407
|
q[bool] => sub { 1 }, |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
require Carp; |
|
21
|
|
|
|
|
|
|
*CarpInternal = \%Carp::CarpInternal; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our %CarpInternal; |
|
24
|
|
|
|
|
|
|
$CarpInternal{$_}++ for @Type::Tiny::InternalPackages; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
860
|
|
|
860
|
1
|
2062
|
my $class = shift; |
|
28
|
860
|
50
|
|
|
|
4428
|
my %params = ( @_ == 1 ) ? %{ $_[0] } : @_; |
|
|
0
|
|
|
|
|
0
|
|
|
29
|
860
|
|
|
|
|
3758
|
return bless \%params, $class; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub throw { |
|
33
|
441
|
|
|
441
|
1
|
30984
|
my $next = $_[0]->can( 'throw_cb' ); |
|
34
|
441
|
|
|
|
|
1306
|
splice( @_, 1, 0, undef ); |
|
35
|
441
|
|
|
|
|
1294
|
goto $next; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub throw_cb { |
|
39
|
859
|
|
|
859
|
1
|
2205
|
my $class = shift; |
|
40
|
859
|
|
|
|
|
1422
|
my $callback = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
859
|
|
|
|
|
1859
|
my ( $level, @caller, %ctxt ) = 0; |
|
43
|
859
|
|
|
|
|
1385
|
while ( |
|
44
|
|
|
|
|
|
|
do { |
|
45
|
2399
|
|
|
|
|
4094
|
my $caller = caller $level; |
|
46
|
2399
|
50
|
|
|
|
9329
|
defined $caller and $CarpInternal{$caller}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
1540
|
|
|
|
|
2382
|
$level++; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
859
|
100
|
100
|
|
|
9145
|
if ( ( ( caller( $level - 1 ) )[1] || "" ) =~ |
|
53
|
|
|
|
|
|
|
/^(?:parameter validation for|exportable function) '(.+?)'$/ ) |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
640
|
|
|
|
|
3975
|
my ( $pkg, $func ) = ( $1 =~ m{^(.+)::(\w+)$} ); |
|
56
|
640
|
100
|
50
|
|
|
2699
|
$level++ if caller( $level ) eq ( $pkg || "" ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Moo's Method::Generate::Constructor puts an eval in the stack trace, |
|
60
|
|
|
|
|
|
|
# that is useless for debugging, so show the stack frame one above. |
|
61
|
859
|
50
|
33
|
|
|
6258
|
$level++ |
|
62
|
|
|
|
|
|
|
if ( |
|
63
|
|
|
|
|
|
|
( caller( $level ) )[1] =~ /^\(eval \d+\)$/ |
|
64
|
|
|
|
|
|
|
and ( caller( $level ) )[3] eq '(eval)' # (caller())[3] is $subroutine |
|
65
|
|
|
|
|
|
|
); |
|
66
|
859
|
|
|
|
|
5106
|
@ctxt{qw/ package file line /} = caller( $level ); |
|
67
|
|
|
|
|
|
|
|
|
68
|
859
|
|
|
|
|
1924
|
my $stack = undef; |
|
69
|
859
|
100
|
|
|
|
2077
|
if ( our $StackTrace ) { |
|
70
|
1
|
|
|
|
|
4
|
require Devel::StackTrace; |
|
71
|
1
|
|
|
|
|
21
|
$stack = "Devel::StackTrace"->new( |
|
72
|
|
|
|
|
|
|
ignore_package => [ keys %CarpInternal ], |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
859
|
|
|
|
|
3841
|
our $LastError = $class->new( |
|
77
|
|
|
|
|
|
|
context => \%ctxt, |
|
78
|
|
|
|
|
|
|
stack_trace => $stack, |
|
79
|
|
|
|
|
|
|
@_, |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
|
|
82
|
859
|
100
|
|
|
|
7737
|
$callback ? $callback->( $LastError ) : die( $LastError ); |
|
83
|
|
|
|
|
|
|
} #/ sub throw |
|
84
|
|
|
|
|
|
|
|
|
85
|
756
|
|
66
|
756
|
1
|
7439
|
sub message { $_[0]{message} ||= $_[0]->_build_message } |
|
86
|
744
|
|
|
744
|
1
|
2838
|
sub context { $_[0]{context} } |
|
87
|
3
|
|
|
3
|
1
|
2501
|
sub stack_trace { $_[0]{stack_trace} } |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub to_string { |
|
90
|
394
|
|
|
394
|
1
|
1593
|
my $e = shift; |
|
91
|
394
|
|
|
|
|
1121
|
my $c = $e->context; |
|
92
|
394
|
|
|
|
|
1080
|
my $m = $e->message; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$m =~ /\n\z/s |
|
95
|
|
|
|
|
|
|
? $m |
|
96
|
|
|
|
|
|
|
: $c ? sprintf( |
|
97
|
|
|
|
|
|
|
"%s at %s line %s.\n", $m, $c->{file} || 'file?', |
|
98
|
394
|
50
|
50
|
|
|
5326
|
$c->{line} || 'NaN' |
|
|
|
50
|
50
|
|
|
|
|
|
99
|
|
|
|
|
|
|
) |
|
100
|
|
|
|
|
|
|
: sprintf( "%s\n", $m ); |
|
101
|
|
|
|
|
|
|
} #/ sub to_string |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub _build_message { |
|
104
|
1
|
|
|
1
|
|
7
|
return 'An exception has occurred'; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub croak { |
|
108
|
139
|
|
|
139
|
1
|
429
|
my ( $fmt, @args ) = @_; |
|
109
|
139
|
|
|
|
|
725
|
@_ = ( |
|
110
|
|
|
|
|
|
|
__PACKAGE__, |
|
111
|
|
|
|
|
|
|
message => sprintf( $fmt, @args ), |
|
112
|
|
|
|
|
|
|
); |
|
113
|
139
|
|
|
|
|
599
|
goto \&throw; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |