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 31     31   165203 use v5.12;
  31         98  
6 31     31   134 use strict;
  31         53  
  31         725  
7 31     31   134 use warnings;
  31         56  
  31         2048  
8              
9             our $VERSION = '2.03';
10              
11 31     31   10234 use Exporter::Shiny qw( error );
  31         137021  
  31         191  
12              
13 31         233 use custom::failures ( qw[
14             attribute::value
15             method::stub
16 31     31   13694 ] );
  31         141555  
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28             sub _exporter_validate_opts {
29 94     94   15512 my $class = shift;
30              
31 94         211 my ( $globals ) = @_;
32              
33 94 100       370 if ( defined $globals->{errors} ) {
34              
35 73         972 my @classes = @{ delete $globals->{errors}; };
  73         238  
36              
37 73 50       200 if ( @classes ) {
38 73         283 $_ = _resolve_class( $_, $globals->{into} ) foreach @classes;
39 73         649 custom::failures->import( @classes );
40             }
41             }
42              
43 94         20004 $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 19 my $class = shift;
60 9         36 _resolve_class( $class, scalar caller(), __PACKAGE__ )->throw( @_ );
61             }
62              
63             sub _resolve_class {
64 123     123   260 my ( $class, $caller, @prefix ) = @_;
65              
66             return join(
67             q{::}, @prefix,
68 123         213 do {
69 123 100       656 if ( $class =~ /^::(.*)/ ) {
    100          
70 41         173 $1;
71             }
72             elsif ( $caller =~ /Data::Record::Serialize::(.*)/ ) {
73 80         489 $1 . q{::} . $class;
74             }
75             else {
76 2         41 $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__