File Coverage

lib/ExtUtils/XSpp/Exception/code.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 4 50.0
condition 2 6 33.3
subroutine 6 6 100.0
pod 1 2 50.0
total 35 42 83.3


line stmt bran cond sub pod time code
1             package ExtUtils::XSpp::Exception::code;
2 21     21   118 use strict;
  21         47  
  21         692  
3 21     21   113 use warnings;
  21         40  
  21         567  
4 21     21   100 use base 'ExtUtils::XSpp::Exception';
  21         42  
  21         10136  
5              
6 1 50 33 1   9 sub _dl { return defined( $_[0] ) && length( $_[0] ) ? $_[0] : undef }
7              
8             sub init {
9 1     1 0 3 my $this = shift;
10 1         7 $this->SUPER::init(@_);
11 1         3 my %args = @_;
12              
13 1   33     10 $this->{HANDLER_CODE} = _dl( $args{handler_code} || $args{arg1} );
14             }
15              
16             sub handler_code {
17 1     1 1 2 my $this = shift;
18 1         2 my $no_spaces_indent = shift;
19 1 50       4 $no_spaces_indent = 4 if not defined $no_spaces_indent;
20              
21 1         18 my $ctype = $this->cpp_type;
22 1         4 my $user_code = $this->{HANDLER_CODE};
23 1         4 $user_code =~ s/^\s+//;
24 1         5 $user_code =~ s/\s+$//;
25 1         8 $user_code = $this->indent_code($user_code, 2);
26 1         4 my $code = <
27             catch ($ctype& e) {
28             $user_code
29             }
30             HERE
31 1         5 return $this->indent_code($code, $no_spaces_indent);
32             }
33              
34             1;