WebApp/Error.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 35 / 35 CC 3 SCAR 4.1
CC
3
Cov
100%
new
2.0
flag
2.0
BEGIN
1.0
CRAP 1.5
« WebApp/Segment/Session/Loader.pm ↑ Summary WebApp/Session/Factory.pm »
1 =head1 NAME
2  
3 OpenFrame::WebApp::Error - base class for WebApp Errors.
4  
5 =head1 SYNOPSIS
6  
7 # meant to be sub-classed:
8 use OpenFrame::WebApp::Error::SomeClass;
9  
10 # should export some error flags to your namespace
11  
12 use Error qw( :try );
13 try {
14 throw OpenFrame::WebApp::Error::SomeClass( flag => eSomeError );
15 } catch OpenFrame::WebApp::Error::SomeClass with {
16 my $e = shift;
17 do { ... } if ($e->flag == eSomeError);
18 }
19  
20 =cut
21  
22  
23 package OpenFrame::WebApp::Error;
24  
25 8 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 8 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 8 our $VERSION = (split(/ /, ' $Revision: 1.3 $ '))[2];
30  
31 8 ▶use base qw( Error );
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 5 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
34 5 my $class = shift;
35 5 local $Error::Depth = $Error::Depth + 1;
36 5 ▶ $class->SUPER::new(map { /^\-?flag$/ ? '-text' : $_; } @_);
Branch: 1 branch
BranchTrueFalseTotal
/^\-?flag$/ ? : 4 14 18
37 }
38  
39 # store flag in '-text' as it's hard-coded into Error.pm
40 7 ▶sub flag {
Subroutine flag: called CC=2 SCAR=6.9
Pod documented
41 7 my $self = shift;
42 7 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 1 6 7
43 1 $self->{-text} = shift;
44 1 return $self;
45 } else {
46 6 return $self->{-text};
47 }
48 }
49  
50  
51 8 1;
52  
53  
54 __END__
« WebApp/Segment/Session/Loader.pm ↑ Summary WebApp/Session/Factory.pm »