blib/lib/MooseX/Error/Exception/Class.pm

filter: Statementstmt 42.8% 15 / 35 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 66.6% 2 / 3 totaltotal 36.2% 21 / 58 CC 7 SCAR 25.5
CC
7
Cov
32%
_create_error
30.0
full_message
6.0
full_message
6.0
CRAP 12.9
↑ Summary
1 package MooseX::Error::Exception::Class;
2  
3 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.099';
8 2 $VERSION = eval { return $VERSION };
9  
10 2 ▶use Exception::Class 1.29 (
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 'Exception::Moose' => {
12 'description' => 'Error',
13 'fields' => [qw(message longmess)],
14 },
15 'Exception::Moose::Validation' => {
16 'description' => 'Validation error',
17 'isa' => 'Exception::Moose',
18 'fields' => [qw(attribute type value message longmess)],
19 },
20 2 );
21  
22 0 ▶sub Exception::Moose::full_message { ## no critic 'Capitalization'
Subroutine full_message: not called CC=2 SCAR=17.9
Pod documented
23 0 my $self = shift;
24  
25 0 my $string =
26 $self->description() . ': '
27 . $self->message() . "\n"
28 . ' Time error caught: '
29 . localtime() . "\n";
30  
31 # Add trace to it if asked for.
32 0 ▶ if ( ( $self->longmess() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->longmess) 0 0 0
33 0 $string .= "\n" . $self->trace() . "\n";
34 }
35  
36 0 return $string;
37 } ## end sub Exception::Moose::full_message
38  
39 sub Exception::Moose::Validation::full_message
40 0 ▶{ ## no critic 'Capitalization'
Subroutine full_message: not called CC=2 SCAR=17.9
Pod documented
41 0 my $self = shift;
42  
43 0 my $string =
44 $self->description()
45 . qq{:\n '}
46 . $self->attribute()
47 . q{' not }
48 . $self->type()
49 . q{ (value passed in: '}
50 . $self->value
51 . qq{')\n}
52 . ' Time error caught: '
53 . localtime() . "\n";
54  
55 # Add trace to it if asked for.
56 0 ▶ if ( ( $self->longmess() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->longmess) 0 0 0
57 0 $string .= "\n" . $self->trace() . "\n";
58 }
59  
60 0 return $string;
61 } ## end sub Exception::Moose::Validation::full_message
62  
63 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my ( $self, @args ) = @_;
65 0 return $self->_create_error(@args);
66 }
67  
68 0 ▶sub _create_error {
Subroutine _create_error: not called CC=5 SCAR=34.0
69 0 my ( $self, %args ) = @_;
70  
71 0 ▶ my @args = exists $args{message} ? $args{message} : ();
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'message'} ? : 0 0 0
72 0 my $info = join q{}, @args;
73  
74 0 ▶ if ($info =~ m{\A
Branch: 1 branch
BranchTrueFalseTotal
if ($info =~ /\A Attribute [ ] \((.*)\) # $1 = attribute name [ ] does [ ] not [ ] pass [ ] the [ ] type [ ] constraint [ ] because: [ ] Validation [ ] failed [ ] for [ ] '(.*)' # $2 = type [ ] failed [ ] with [ ] value [ ] (.*) # $3 = bad value \z/msx) { } 0 0 0
75 Attribute [ ] \((.*)\) # $1 = attribute name
76 [ ] does [ ] not [ ] pass [ ] the
77 [ ] type [ ] constraint [ ] because:
78 [ ] Validation [ ] failed [ ] for [ ] '(.*)' # $2 = type
79 [ ] failed [ ] with [ ] value [ ] (.*) # $3 = bad value
80 \z}msx
81 )
82 {
83 0 my ( $attr_name, $attr_type, $value ) = ( $1, $2, $3 );
84  
85 Exception::Moose::Validation->throw(
86 message => $info,
87 attribute => $attr_name,
88 type => $attr_type,
89 value => $value,
90 0 ▶ longmess => exists $args{longmess} ? !!$args{longmess} : 1,
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'longmess'} ? : 0 0 0
91 ignore_class =>
92 [qw(MooseX::Error::Exception::Class Moose::Meta::Class)],
93 );
94 } else {
95 Exception::Moose->throw(
96 message => $info,
97 0 ▶ longmess => exists $args{longmess} ? !!$args{longmess} : 0,
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'longmess'} ? : 0 0 0
98 ignore_class =>
99 [qw(MooseX::Error::Exception::Class Moose::Meta::Class)],
100 );
101 }
102  
103 0 return;
104 } ## end sub _create_error
105  
106 2 1; # Magic true value required at end of module
107  
108 __END__
↑ Summary