OpenInteract2/Exception.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 16.6% 1 / 6 totaltotal 90.2% 46 / 51 CC 2 SCAR 1.7
CC
2
Cov
100%
_massage
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« OpenInteract2/Brick/Apache.pm ↑ Summary OpenInteract2/Brick/WebsiteConfig.pm »
1 package OpenInteract2::Exception;
2  
3 # $Id: Exception.pm,v 1.12 2005/03/17 14:57:58 sjn Exp $
4  
5 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 87 ▶use Carp qw( carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 87 $OpenInteract2::Exception::VERSION = sprintf("%d.%02d", q$Revision: 1.12 $ =~ /(\d+)\.(\d+)/);
9  
10 # Declare some of our exceptions
11  
12 87 ▶use Exception::Class (
Subroutine BEGIN: called CC=1 SCAR=0.0
13 87 'OpenInteract2::Exception::Application' => {
14 isa => 'OpenInteract2::Exception',
15 description => 'Generic application errors',
16 fields => [ 'oi_package' ],
17 },
18 'OpenInteract2::Exception::Datasource' => {
19 isa => 'OpenInteract2::Exception',
20 description => 'Datasource errors',
21 fields => [ 'datasource_name', 'datasource_type', 'connect_params' ],
22 },
23 87 );
24  
25 87 @OpenInteract2::Exception::ISA = qw( Exporter Exception::Class::Base );
26 87 @OpenInteract2::Exception::EXPORT_OK = qw(
27 oi_error oi_app_error oi_datasource_error oi_param_error oi_security_error
28 );
29  
30 87 require OpenInteract2::Exception::Parameter;
31 87 require OpenInteract2::Exception::Security;
32  
33 # Exported shortcuts
34  
35 22 ▶sub oi_error {
Subroutine oi_error: called CC=1 SCAR=0.0
Pod undocumented
36 # carp "throwing oi_error...";
37 22 my ( $msg, %params ) = _massage( @_ );
38 22 goto &Exception::Class::Base::throw( __PACKAGE__,
39 message => $msg, %params );
40 }
41  
42 1 ▶sub oi_app_error {
Subroutine oi_app_error: called CC=1 SCAR=0.0
Pod undocumented
43 # carp "throwing oi_app_error...";
44 1 my ( $msg, %params ) = _massage( @_ );
45 1 goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Application',
46 message => $msg, %params );
47 }
48  
49 1 ▶sub oi_datasource_error {
Subroutine oi_datasource_error: called CC=1 SCAR=0.0
Pod undocumented
50 # carp "throwing oi_datasource_error...";
51 1 my ( $msg, %params ) = _massage( @_ );
52 1 goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Datasource',
53 message => $msg, %params );
54 }
55  
56 1 ▶sub oi_param_error {
Subroutine oi_param_error: called CC=1 SCAR=0.0
Pod undocumented
57 # carp "throwing oi_param_error...";
58 1 my ( $msg, %params ) = _massage( @_ );
59 1 goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Parameter',
60 message => $msg, %params );
61 }
62  
63 1 ▶sub oi_security_error {
Subroutine oi_security_error: called CC=1 SCAR=0.0
Pod undocumented
64 # carp "throwing oi_security_error...";
65 1 my ( $msg, %params ) = _massage( @_ );
66 1 goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Security',
67 message => $msg, %params );
68 }
69  
70 # Override 'throw' so we can massage the message and parameters into
71 # the right format for E::C
72  
73 9 ▶sub throw {
Subroutine throw: called CC=1 SCAR=0.0
Pod documented
74 9 my $class = shift @_;
75 9 my ( $msg, %params ) = _massage( @_ );
76 9 goto &Exception::Class::Base::throw( $class, message => $msg, %params );
77 }
78  
79 35 ▶sub _massage {
Subroutine _massage: called CC=2 SCAR=6.9
80 35 my @items = @_;
81 my %params = ( ref $items[-1] eq 'HASH' )
82 35 ▶ ? %{ pop( @items ) } : ();
Branch: 1 branch
BranchTrueFalseTotal
ref $items[-1] eq 'HASH' ? : 10 25 35
83 35 my $msg = join( '', @items );
84 35 return ( $msg, %params );
85 }
86  
87 87 1;
88  
89 __END__
« OpenInteract2/Brick/Apache.pm ↑ Summary OpenInteract2/Brick/WebsiteConfig.pm »