File Coverage

blib/lib/Protocol/ACME/Exception.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 4 0.0
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 12 31 38.7


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