File Coverage

lib/ExtUtils/XSpp/Exception/object.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 4 50.0
condition 2 6 33.3
subroutine 6 6 100.0
pod 1 2 50.0
total 34 41 82.9


line stmt bran cond sub pod time code
1             package ExtUtils::XSpp::Exception::object;
2 21     21   124 use strict;
  21         45  
  21         679  
3 21     21   115 use warnings;
  21         42  
  21         6306  
4 21     21   112 use base 'ExtUtils::XSpp::Exception';
  21         40  
  21         826  
5              
6 1 50 33 1   17 sub _dl { return defined( $_[0] ) && length( $_[0] ) ? $_[0] : undef }
7              
8             sub init {
9 1     1 0 2 my $this = shift;
10 1         8 $this->SUPER::init(@_);
11 1         3 my %args = @_;
12              
13 1   33     10 $this->{PERL_EXCEPTION_CLASS} = _dl( $args{perl_class} || $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         10 my $ctype = $this->cpp_type;
22 1         2 my $pclass = $this->{PERL_EXCEPTION_CLASS};
23 1         5 $pclass =~ s/^\s+//;
24 1         4 $pclass =~ s/\s+$//;
25 1         3 my $code = <
26             catch ($ctype& e) {
27             SV* errsv;
28             SV* objsv;
29             objsv = eval_pv("$pclass->new()", 1);
30             errsv = get_sv("@", TRUE);
31             sv_setsv(errsv, exception_object);
32             croak(NULL);
33             }
34             HERE
35 1         8 return $this->indent_code($code, $no_spaces_indent);
36             }
37              
38             1;