| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
|
3
|
30
|
|
|
30
|
|
182
|
use warnings; |
|
|
30
|
|
|
|
|
46
|
|
|
|
30
|
|
|
|
|
714
|
|
|
4
|
30
|
|
|
30
|
|
124
|
|
|
|
30
|
|
|
|
|
41
|
|
|
|
30
|
|
|
|
|
773
|
|
|
5
|
|
|
|
|
|
|
use overload |
|
6
|
|
|
|
|
|
|
q{""} => 'as_string', |
|
7
|
30
|
|
|
|
|
174
|
fallback => 1; |
|
8
|
30
|
|
|
30
|
|
125
|
|
|
|
30
|
|
|
|
|
42
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.48'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Devel::StackTrace; |
|
12
|
30
|
|
|
30
|
|
13383
|
use Scalar::Util qw( blessed ); |
|
|
30
|
|
|
|
|
78352
|
|
|
|
30
|
|
|
|
|
811
|
|
|
13
|
30
|
|
|
30
|
|
231
|
use Specio::OO; |
|
|
30
|
|
|
|
|
50
|
|
|
|
30
|
|
|
|
|
1123
|
|
|
14
|
30
|
|
|
30
|
|
146
|
|
|
|
30
|
|
|
|
|
52
|
|
|
|
30
|
|
|
|
|
5431
|
|
|
15
|
|
|
|
|
|
|
{ |
|
16
|
|
|
|
|
|
|
my $attrs = { |
|
17
|
|
|
|
|
|
|
message => { |
|
18
|
|
|
|
|
|
|
isa => 'Str', |
|
19
|
|
|
|
|
|
|
required => 1, |
|
20
|
|
|
|
|
|
|
}, |
|
21
|
|
|
|
|
|
|
type => { |
|
22
|
|
|
|
|
|
|
does => 'Specio::Constraint::Role::Interface', |
|
23
|
|
|
|
|
|
|
required => 1, |
|
24
|
|
|
|
|
|
|
}, |
|
25
|
|
|
|
|
|
|
value => { |
|
26
|
|
|
|
|
|
|
required => 1, |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
stack_trace => { |
|
29
|
|
|
|
|
|
|
init_arg => undef, |
|
30
|
|
|
|
|
|
|
}, |
|
31
|
|
|
|
|
|
|
}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
|
34
|
|
|
|
|
|
|
return $attrs; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
60
|
|
|
60
|
|
118
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $self = shift; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->{stack_trace} |
|
41
|
2866
|
|
|
2866
|
0
|
63879
|
= Devel::StackTrace->new( ignore_package => __PACKAGE__ ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return; |
|
44
|
2866
|
|
|
|
|
9392
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
2866
|
|
|
|
|
2260427
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $str = $self->message; |
|
49
|
|
|
|
|
|
|
$str .= "\n\n" . $self->stack_trace->as_string; |
|
50
|
5731
|
|
|
5731
|
1
|
214380
|
|
|
51
|
|
|
|
|
|
|
return $str; |
|
52
|
5731
|
|
|
|
|
15932
|
} |
|
53
|
5731
|
|
|
|
|
24992
|
|
|
54
|
|
|
|
|
|
|
my $self = shift; |
|
55
|
5731
|
|
|
|
|
7708635
|
|
|
56
|
|
|
|
|
|
|
die $self if blessed $self; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
die $self->new(@_); |
|
59
|
2866
|
|
|
2866
|
0
|
4839
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
2866
|
50
|
|
|
|
7166
|
__PACKAGE__->_ooify; |
|
62
|
|
|
|
|
|
|
|
|
63
|
2866
|
|
|
|
|
8663
|
1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# ABSTRACT: An exception class for type constraint failures |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Specio::Exception - An exception class for type constraint failures |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 0.48 |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
use Try::Tiny; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
try { |
|
85
|
|
|
|
|
|
|
$type->validate_or_die($value); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
catch { |
|
88
|
|
|
|
|
|
|
if ( $_->isa('Specio::Exception') ) { |
|
89
|
|
|
|
|
|
|
print $_->message, "\n"; |
|
90
|
|
|
|
|
|
|
print $_->type->name, "\n"; |
|
91
|
|
|
|
|
|
|
print $_->value, "\n"; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This exception class is thrown by Specio when a type check fails. It emulates |
|
98
|
|
|
|
|
|
|
the L<Throwable::Error> API, but doesn't use that module to avoid adding a |
|
99
|
|
|
|
|
|
|
dependency on L<Moo>. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=for Pod::Coverage BUILD throw |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 API |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This class provides the following methods: |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 $exception->message |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The error message associated with the exception. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 $exception->stack_trace |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
A L<Devel::StackTrace> object for the exception. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 $exception->type |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The type constraint object against which the value failed. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 $exception->value |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The value that failed the type check. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 $exception->as_string |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The exception as a string. This includes the method and the stack trace. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 OVERLOADING |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This class overloads stringification to call the C<as_string> method. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SUPPORT |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SOURCE |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 AUTHOR |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This software is Copyright (c) 2012 - 2022 by Dave Rolsky. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This is free software, licensed under: |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
152
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |