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   19 use strict;
  6         5  
  6         121  
4 6     6   16 use warnings;
  6         9  
  6         219  
5              
6             our $VERSION = '1.01';
7              
8             # very simple stringification ... make this
9             # more elaborate according to taste
10 6     6   940 use overload ('""' => \&stringify);
  6         680  
  6         27  
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         3 my $error = shift;
24 2         8 my $self = { status => 0, detail => "", type => "unknown" };
25              
26 2 50       7 if ( ref $error eq "HASH" )
    0          
27             {
28 2         6 @$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         34 return bless $self, $class;
40             }
41              
42             1;