blib/lib/Error/Unhandled.pm

filter: Statementstmt 100% 26 / 26 Branchbran 83.3% 10 / 12 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 80.0% 4 / 5 Podpod 50.0% 1 / 2 totaltotal 92.0% 46 / 50 CC 8 SCAR 17.4
CC
8
Cov
95%
throw
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
↑ Summary
1 ##########################################################################
2 #
3 # Error::Unhandled - a Module for letting Errors do their own handling
4 #
5 # Author: Toby Everett
6 # Revision: 1.02
7 # Last Change: Fixed Makefile.pl bug
8 ##########################################################################
9 # Copyright 1995 Graham Barr, 1999 Toby Everett. All rights reserved.
10 #
11 # This file is distributed under the Artistic License. See
12 # http://www.ActiveState.com/corporate/artistic_license.htm or
13 # the license that comes with your perl distribution.
14 #
15 # For comments, questions, bugs or general interest, feel free to
16 # contact Toby Everett at teverett@alascom.att.com
17 #
18 # Graham Barr was responsible for the prototype throw method which I copied
19 # and extended to implement this throw method.
20 ##########################################################################
21  
22 1 ▶use Error 0.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 package Error::Unhandled;
25  
26 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 1 @ISA = qw(Error);
30  
31 1 $VERSION = '1.02';
32  
33 4 ▶sub throw {
Subroutine throw: called CC=8 SCAR=20.8
Pod documented
34 4 my $self = shift;
35 4 local $Error::Depth = $Error::Depth + 1;
36  
37 # if we are not rethrow-ing then create the object to throw
38 4 ▶ $self = $self->new(@_) unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 4 0 4
39  
40 4 my $i = 0;
41 4 my $handled = 0;
42 4 ▶ while(my $subname = (caller($i++))[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $subname = (caller $i++)[3]) 13 2 15
43 13 ▶ if ($subname eq '(eval)' && (caller($i))[3] eq 'Error::subs::try') {
Branch: 1 branch
BranchTrueFalseTotal
if ($subname eq "(eval)" and (caller $i)[3] eq "Error::subs::try") 2 11 13
Condition100%3/3
$subname eq "(eval)" and (caller $i)[3] eq "Error::subs::try"
!ll&&!rl&&r
1012
MC/DC100%2/2
$subname eq "(eval)" and (caller $i)[3] eq "Error::subs::try"
$subname eq "(eval)" (caller $i)[3] eq "Error::subs::try"
Truth table100%3/3
A and B
A= $subname eq "(eval)"B= (caller $i)[3] eq "Error::subs::try"
ABresult
0X0
100
111
44 2 $handled = 1;
45 2 last;
46 }
47 }
48 4 ▶ unless ($handled) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($handled) 2 2 4
49 2 ▶ if (exists $self->{unhandled}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'unhandled'}) { } 1 1 2
50 1 ▶ ref($self->{unhandled}) eq 'CODE' and $self->{unhandled}->($self);
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{"unhandled"} eq "CODE" and $self->{"unhandled"}->($self) 1 0 1
51 } else {
52 1 $self->unhandled;
53 }
54 }
55 3 die $Error::THROWN = $self;
56 }
57  
58 0 ▶sub unhandled {
Subroutine unhandled: not called CC=1 SCAR=0.0
Pod undocumented
59 }
60  
61 1 1;
62  
63 __END__
↑ Summary