File Coverage

blib/lib/Error/TypeTiny/Compilation.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition 1 2 50.0
subroutine 8 8 100.0
pod 3 3 100.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Error::TypeTiny::Compilation;
2              
3 4     4   1030 use 5.008001;
  4         14  
4 4     4   23 use strict;
  4         9  
  4         82  
5 4     4   19 use warnings;
  4         5  
  4         166  
6              
7             BEGIN {
8 4     4   22 $Error::TypeTiny::Compilation::AUTHORITY = 'cpan:TOBYINK';
9 4         759 $Error::TypeTiny::Compilation::VERSION = '2.003_000';
10             }
11              
12             $Error::TypeTiny::Compilation::VERSION =~ tr/_//d;
13              
14             require Error::TypeTiny;
15             our @ISA = 'Error::TypeTiny';
16              
17 4     4 1 1031 sub code { $_[0]{code} }
18 1   50 1 1 13 sub environment { $_[0]{environment} ||= {} }
19 6     6 1 392 sub errstr { $_[0]{errstr} }
20              
21             sub _build_message {
22 2     2   5 my $self = shift;
23 2         6 sprintf( "Failed to compile source because: %s", $self->errstr );
24             }
25              
26             1;
27              
28             __END__
29              
30             =pod
31              
32             =encoding utf-8
33              
34             =head1 NAME
35              
36             Error::TypeTiny::Compilation - exception for Eval::TypeTiny
37              
38             =head1 STATUS
39              
40             This module is covered by the
41             L<Type-Tiny stability policy|Type::Tiny::Manual::Policies/"STABILITY">.
42              
43             =head1 DESCRIPTION
44              
45             Thrown when compiling a closure fails. Common causes are problems with
46             inlined type constraints, and syntax errors when coercions are given as
47             strings of Perl code.
48              
49             This package inherits from L<Error::TypeTiny>; see that for most
50             documentation. Major differences are listed below:
51              
52             =head2 Attributes
53              
54             =over
55              
56             =item C<code>
57              
58             The Perl source code being compiled.
59              
60             =item C<environment>
61              
62             Hashref of variables being closed over.
63              
64             =item C<errstr>
65              
66             Error message from Perl compiler.
67              
68             =back
69              
70             =head1 BUGS
71              
72             Please report any bugs to
73             L<https://github.com/tobyink/p5-type-tiny/issues>.
74              
75             =head1 SEE ALSO
76              
77             L<Error::TypeTiny>.
78              
79             =head1 AUTHOR
80              
81             Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
82              
83             =head1 COPYRIGHT AND LICENCE
84              
85             This software is copyright (c) 2013-2014, 2017-2023 by Toby Inkster.
86              
87             This is free software; you can redistribute it and/or modify it under
88             the same terms as the Perl 5 programming language system itself.
89              
90             =head1 DISCLAIMER OF WARRANTIES
91              
92             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
93             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
94             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.