WiX3/Util/Error.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 65 CC 5 SCAR 24.8
CC
5
Cov
0%
_create_error_carpmess
30.0
new
2.0
create_error_croak
2.0
CRAP 12.0
1 package # Hide from PAUSE
2 WiX3::Util::Error;
3  
4 use 5.008003;
5 use strict;
6 use warnings;
7 use Readonly qw (Readonly);
8 use WiX3::Exceptions;
9 use parent 'Moose::Error::Default';
10  
11 our $VERSION = '0.011';
12  
13 Readonly my %TYPES => ( 'Maybe[Int]' => 'an integer' );
14  
15 sub new {
16 my ( $self, @args ) = @_;
17 return $self->create_error_croak(@args);
18 }
19  
20 sub create_error_croak {
21 my ( $self, @args ) = @_;
22 return $self->_create_error_carpmess(@args);
23 }
24  
25 sub create_error_confess {
26 my ( $self, @args ) = @_;
27 return $self->_create_error_carpmess( @args, longmess => 1 );
28 }
29  
30 sub _create_error_carpmess {
31 my ( $self, %args ) = @_;
32  
33 ## no critic(ProhibitMagicNumbers)
34 my $carp_level = 3 + ( $args{depth} || 1 );
35  
36 my @args = exists $args{message} ? $args{message} : ();
37 my $info = join q{}, @args;
38  
39 my $longmess = exists $args{longmess} ? !!$args{longmess} : 0;
40  
41 ## no critic(ProhibitComplexRegexes)
42 if ($info =~ m{\A
43 Attribute [ ] [(] (.*) [)] # $1 = attribute name
44 [ ] does [ ] not [ ] pass [ ] the
45 [ ] type [ ] constraint [ ] because:
46 [ ] Validation [ ] failed [ ] for [ ] '(.*)' # $2 = type
47 (?:[ ] failed)? [ ] with [ ] value [ ] (.*) # $3 = bad value
48 \z}msx
49 )
50 {
51 my ( $attr_name, $attr_type, $value ) = ( $1, $2, $3 );
52 my $type =
53 exists $TYPES{$attr_type} ? $TYPES{$attr_type} : $attr_type;
54  
55 WiX3::Exception::Parameter::Validation->throw(
56 attribute => $attr_name,
57 type => $type,
58 value => $value,
59 ignore_class => [qw(WiX3::Util::Error Moose::Meta::Class)],
60 );
61 } else {
62 WiX3::Exception::Caught->throw(
63 message => 'Moose',
64 info => $info,
65 longmess => $longmess,
66 ignore_class => [qw(WiX3::Util::Error Moose::Meta::Class)],
67 );
68 }
69 return;
70 } ## end sub _create_error_carpmess
71  
72 1;
73  
74 __END__