File Coverage

blib/lib/Kubernetes/REST/Error.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 1 2 50.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Kubernetes::REST::Error;
2 4     4   74301 use Moo;
  4         22514  
  4         25  
3 4     4   5161 use Types::Standard qw/Str/;
  4         225964  
  4         40  
4             extends 'Throwable::Error';
5              
6             has type => (is => 'ro', isa => Str, required => 1);
7             has detail => (is => 'ro');
8              
9             sub header {
10 10     10 0 14 my $self = shift;
11 10         102 return sprintf "Exception with type: %s: %s", $self->type, $self->message;
12             }
13              
14             sub as_string {
15 10     10 1 10697 my $self = shift;
16 10 100       39 if (defined $self->detail) {
17 6         84 return sprintf "%s\nDetail: %s", $self->header, $self->detail;
18             } else {
19 4         58 return $self->header;
20             }
21             }
22              
23             package Kubernetes::REST::RemoteError;
24 4     4   3625 use Moo;
  4         10  
  4         27  
25 4     4   1448 use Types::Standard qw/Int/;
  4         10  
  4         18  
26             extends 'Kubernetes::REST::Error';
27              
28             has '+type' => (default => sub { 'Remote' });
29             has status => (is => 'ro', isa => Int, required => 1);
30              
31             around header => sub {
32             my ($orig, $self) = @_;
33             my $orig_message = $self->$orig;
34             sprintf "%s with HTTP status %d", $orig_message, $self->status;
35             };
36              
37             1;