File Coverage

blib/lib/Data/Record/Serialize/Error.pm
Criterion Covered Total %
statement 31 31 100.0
branch 7 8 87.5
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 47 48 97.9


line stmt bran cond sub pod time code
1             package Data::Record::Serialize::Error;
2              
3             # ABSTRACT: Error objects
4              
5 30     30   257470 use v5.12;
  30         125  
6 30     30   192 use strict;
  30         99  
  30         853  
7 30     30   172 use warnings;
  30         69  
  30         2643  
8              
9             our $VERSION = '2.02';
10              
11 30     30   14301 use Exporter::Shiny qw( error );
  30         194205  
  30         249  
12              
13 30         326 use custom::failures ( qw[
14             attribute::value
15             method::stub
16 30     30   18398 ] );
  30         198096  
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28             sub _exporter_validate_opts {
29 90     90   20501 my $class = shift;
30              
31 90         295 my ( $globals ) = @_;
32              
33 90 100       465 if ( defined $globals->{errors} ) {
34              
35 70         174 my @classes = @{ delete $globals->{errors}; };
  70         279  
36              
37 70 50       1127 if ( @classes ) {
38 70         389 $_ = _resolve_class( $_, $globals->{into} ) foreach @classes;
39 70         731 custom::failures->import( @classes );
40             }
41             }
42              
43 90         30034 $class->SUPER::_exporter_validate_opts( @_ );
44             }
45              
46              
47              
48              
49              
50              
51              
52              
53              
54              
55              
56              
57              
58             sub error {
59 9     9 1 21 my $class = shift;
60 9         46 _resolve_class( $class, scalar caller(), __PACKAGE__ )->throw( @_ );
61             }
62              
63             sub _resolve_class {
64 117     117   382 my ( $class, $caller, @prefix ) = @_;
65              
66             return join(
67             q{::}, @prefix,
68 117         274 do {
69 117 100       898 if ( $class =~ /^::(.*)/ ) {
    100          
70 38         256 $1;
71             }
72             elsif ( $caller =~ /Data::Record::Serialize::(.*)/ ) {
73 77         1591 $1 . q{::} . $class;
74             }
75             else {
76 2         57 $class;
77             }
78             },
79             );
80             }
81              
82             1;
83              
84             #
85             # This file is part of Data-Record-Serialize
86             #
87             # This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
88             #
89             # This is free software, licensed under:
90             #
91             # The GNU General Public License, Version 3, June 2007
92             #
93              
94             __END__