File Coverage

blib/lib/Protocol/ACME/Exception.pm
Criterion Covered Total %
statement 15 20 75.0
branch 1 4 25.0
condition n/a
subroutine 4 5 80.0
pod 0 2 0.0
total 20 31 64.5


line stmt bran cond sub pod time code
1             package Protocol::ACME::Exception;
2              
3 6     6   40 use strict;
  6         12  
  6         173  
4 6     6   30 use warnings;
  6         14  
  6         284  
5              
6             our $VERSION = '1.02';
7              
8             # very simple stringification ... make this
9             # more elaborate according to taste
10 6     6   2467 use overload ('""' => \&stringify);
  6         1968  
  6         52  
11             sub stringify
12             {
13 0     0 0 0 my $self = shift;
14              
15 0         0 require Data::Dumper;
16 0         0 return ref($self).' error: '.Data::Dumper::Dumper($self);
17             }
18              
19             sub new
20             {
21 2     2 0 6 my $class = shift;
22              
23 2         4 my $error = shift;
24 2         12 my $self = { status => 0, detail => "", type => "unknown" };
25              
26 2 50       9 if ( ref $error eq "HASH" )
    0          
27             {
28 2         10 @$self{keys %$error} = values %$error;
29             }
30             elsif ( ref $error )
31             {
32 0         0 $self->{detail} = "double error: bad arg ($error) passed to exception constructor";
33             }
34             else
35             {
36 0         0 $self->{detail} = $error;
37             }
38              
39 2         44 return bless $self, $class;
40             }
41              
42             1;