File Coverage

blib/lib/Template/Liquid/Error.pm
Criterion Covered Total %
statement 6 20 30.0
branch 0 10 0.0
condition n/a
subroutine 2 7 28.5
pod 0 5 0.0
total 8 42 19.0


line stmt bran cond sub pod time code
1             package Template::Liquid::Error;
2             our $VERSION = '1.0.23';
3 26     26   171 use strict;
  26         62  
  26         770  
4 26     26   145 use warnings;
  26         52  
  26         9380  
5 0     0 0   sub message { return $_[0]->{'message'} }
6 0     0 0   sub fatal { return $_[0]->{'fatal'} }
7              
8             sub new {
9 0     0 0   my ($class, $args) = @_;
10 0 0         $args->{'fatal'} = defined $args->{'fatal'} ? $args->{'fatal'} : 0;
11 0           require Carp;
12 0           Carp::longmess() =~ m[^.+?\n\t(.+)]so;
13             $args->{'message'} = sprintf '%s [%s]: %s %s%s', $class, $args->{'type'},
14             $args->{'message'}, $1,
15             (defined $args->{template}
16             ? sprintf(' (at line %d, column %d)',
17             $args->{template}{line},
18             $args->{template}{column})
19 0 0         : ''
20             );
21 0 0         die unless defined $args->{template};
22 0           return bless $args, $class;
23             }
24              
25             sub raise {
26 0     0 0   my ($s) = @_;
27 0 0         $s = ref $s ? $s : $s->new($_[1]);
28 0 0         die $s->message if $s->fatal;
29 0           warn $s->message;
30             }
31 0     0 0   sub render { $_[0]->{message} }
32             1;
33              
34             =pod
35              
36             =encoding UTF-8
37              
38             =head1 NAME
39              
40             Template::Liquid::Error - General Purpose Error Object
41              
42             =head1 Description
43              
44             This is really only to be used internally.
45              
46             =head1 Author
47              
48             Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
49              
50             CPAN ID: SANKO
51              
52             =head1 License and Legal
53              
54             Copyright (C) 2009-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt>
55              
56             This program is free software; you can redistribute it and/or modify it under
57             the terms of L<The Artistic License
58             2.0|http://www.perlfoundation.org/artistic_license_2_0>. See the F<LICENSE>
59             file included with this distribution or L<notes on the Artistic License
60             2.0|http://www.perlfoundation.org/artistic_2_0_notes> for clarification.
61              
62             When separated from the distribution, all original POD documentation is covered
63             by the L<Creative Commons Attribution-Share Alike 3.0
64             License|http://creativecommons.org/licenses/by-sa/3.0/us/legalcode>. See the
65             L<clarification of the
66             CCA-SA3.0|http://creativecommons.org/licenses/by-sa/3.0/us/>.
67              
68             =cut