File Coverage

blib/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   106 use strict;
  21         30  
  21         589  
3 21     21   75 use warnings;
  21         33  
  21         760  
4 21     21   105 use base 'ExtUtils::XSpp::Exception';
  21         39  
  21         753  
5              
6 1 50 33 1   6 sub _dl { return defined( $_[0] ) && length( $_[0] ) ? $_[0] : undef }
7              
8             sub init {
9 1     1 0 1 my $this = shift;
10 1         5 $this->SUPER::init(@_);
11 1         2 my %args = @_;
12              
13 1   33     6 $this->{HANDLER_CODE} = _dl( $args{handler_code} || $args{arg1} );
14             }
15              
16             sub handler_code {
17 1     1 1 1 my $this = shift;
18 1         2 my $no_spaces_indent = shift;
19 1 50       16 $no_spaces_indent = 4 if not defined $no_spaces_indent;
20              
21 1         7 my $ctype = $this->cpp_type;
22 1         3 my $user_code = $this->{HANDLER_CODE};
23 1         4 $user_code =~ s/^\s+//;
24 1         5 $user_code =~ s/\s+$//;
25 1         4 $user_code = $this->indent_code($user_code, 2);
26 1         3 my $code = <
27             catch ($ctype& e) {
28             $user_code
29             }
30             HERE
31 1         3 return $this->indent_code($code, $no_spaces_indent);
32             }
33              
34             1;