blib/lib/Moose/Exception.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 83.3% 10 / 12 Conditioncond 88.8% 8 / 9 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 85.7% 6 / 7 Podpod 50.0% 1 / 2 totaltotal 90.7% 69 / 76 CC 11 SCAR 15.5
CC
11
Cov
94%
as_string
7.0
_build_trace
5.0
_build_message
2.0
CRAP 4.7
« blib/lib/Moose/Meta/Role/Attribute.pm ↑ Summary blib/lib/Moose/Util/TypeConstraints.pm »
1 package Moose::Exception;
2 185 our $VERSION = '2.4001';
3  
4 185 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 185 ▶use Devel::StackTrace 2.03;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 185 has 'trace' => (
8 is => 'ro',
9 isa => 'Devel::StackTrace',
10 builder => '_build_trace',
11 lazy => 1,
12 documentation => "This attribute is read-only and isa L<Devel::StackTrace>. ".
13 'It is lazy & dependent on $exception->message.'
14 );
15  
16 185 has 'message' => (
17 is => 'ro',
18 isa => 'Defined',
19 builder => '_build_message',
20 lazy => 1,
21 documentation => "This attribute is read-only and isa Defined. ".
22 "It is lazy and has a default value 'Error'."
23 );
24  
25 185 ▶use overload(
Subroutine BEGIN: called CC=1 SCAR=0.0
26 q{""} => 'as_string',
27 bool => sub () { 1 },
28 185 fallback => 1,
29 185 );
30  
31 3663 ▶sub _build_trace {
Subroutine _build_trace: called CC=5 SCAR=16.2
32 3663 my $self = shift;
33  
34 # skip frames that are method calls on the exception object, which include
35 # the object itself in the arguments (but Devel::LeakTrace really ought to
36 # be weakening all references in its frames)
37 3663 my $skip = 0;
38 3663 ▶ while (my @c = caller(++$skip)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@c) = caller ++$skip) 11007 0 11007
39 11007 ▶ last if ($c[3] =~ /^(.*)::new$/ || $c[3] =~ /^\S+ (.*)::new \(defined at /)
Branch: 1 branch
BranchTrueFalseTotal
if $c[3] =~ /^(.*)::new$/ || $c[3] =~ /^\S+ (.*)::new \(defined at / and $self->isa($1) 3663 7344 11007
Condition83%5/6
$c[3] =~ /^(.*)::new$/ || $c[3] =~ /^\S+ (.*)::new \(defined at / and $self->isa($1)
!ll&&!rl&&r
734403663
$c[3] =~ /^(.*)::new$/ or $c[3] =~ /^\S+ (.*)::new \(defined at /
l!l&&r!l&&!r
366217344
MC/DC66%2/3
$c[3] =~ /^(.*)::new$/ || $c[3] =~ /^\S+ (.*)::new \(defined at / and $self->isa($1)
$c[3] =~ /^(.*)::new$/ $c[3] =~ /^\S+ (.*)::new \(defined at / $self->isa($1)
Truth table60%3/5
A or B and C
A= $c[3] =~ /^(.*)::new$/B= $c[3] =~ /^\S+ (.*)::new \(defined at /C= $self->isa($1)
ABCresult
00X0
1X00
0100
1X11
0111
40 && $self->isa($1);
41 }
42 3663 $skip++;
43  
44 3663 Devel::StackTrace->new(
45 message => $self->message,
46 indent => 1,
47 skip_frames => $skip,
48 no_refs => 1,
49 );
50 }
51  
52 0 ▶sub _build_message {
Subroutine _build_message: not called CC=1 SCAR=6.9
53 0 "Error";
54 }
55  
56 3680 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
57 3680 my $self = shift;
58 3680 $self->trace;
59 }
60  
61 1605 ▶sub as_string {
Subroutine as_string: called CC=7 SCAR=19.5
Pod documented
62 1605 my $self = shift;
63  
64 1605 ▶ if ( $ENV{MOOSE_FULL_EXCEPTION} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"MOOSE_FULL_EXCEPTION"}) 5 1600 1605
65 5 return $self->trace->as_string;
66 }
67  
68 1600 my @frames;
69 my $last_frame;
70 1600 my $in_moose = 1;
71 1600 for my $frame ( $self->trace->frames ) {
72 18855 ▶ if ( $in_moose && $frame->package =~ /^(?:Moose|Class::MOP)(?::|$)/ )
Branch: 2 branches
BranchTrueFalseTotal
if ($in_moose and $frame->package =~ /^(?:Moose|Class::MOP)(?::|$)/) { } 2115 16740 18855
elsif ($last_frame) { } 433 16307 16740
Condition100%3/3
$in_moose and $frame->package =~ /^(?:Moose|Class::MOP)(?::|$)/
!ll&&!rl&&r
1514016002115
MC/DC100%2/2
$in_moose and $frame->package =~ /^(?:Moose|Class::MOP)(?::|$)/
$in_moose $frame->package =~ /^(?:Moose|Class::MOP)(?::|$)/
Truth table100%3/3
A and B
A= $in_mooseB= $frame->package =~ /^(?:Moose|Class::MOP)(?::|$)/
ABresult
0X0
100
111
73 {
74 2115 $last_frame = $frame;
75 2115 next;
76 }
77 elsif ($last_frame) {
78 433 push @frames, $last_frame;
79 433 undef $last_frame;
80 }
81  
82 16740 $in_moose = 0;
83 16740 push @frames, $frame;
84 }
85  
86 # This would be a somewhat pathological case, but who knows
87 1600 ▶ return $self->trace->as_string unless @frames;
Branch: 1 branch
BranchTrueFalseTotal
unless @frames 0 1600 1600
88  
89 1600 my $message = ( shift @frames )->as_string( 1, {} ) . "\n";
90 1600 $message .= join q{}, map { $_->as_string( 0, {} ) . "\n" } @frames;
91  
92 1600 return $message;
93 }
94  
95 185 __PACKAGE__->meta->make_immutable;
96 185 1;
97  
98 # ABSTRACT: Superclass for Moose internal exceptions
99  
100 __END__
« blib/lib/Moose/Meta/Role/Attribute.pm ↑ Summary blib/lib/Moose/Util/TypeConstraints.pm »