File Coverage

blib/lib/Azure/AD/Errors.pm
Criterion Covered Total %
statement 12 18 66.6
branch 0 2 0.0
condition n/a
subroutine 4 6 66.6
pod 1 2 50.0
total 17 28 60.7


line stmt bran cond sub pod time code
1             # This is a library that loads a bunch of Exception objects
2             package Azure::AD::Error;
3 1     1   6 use Moo;
  1         2  
  1         5  
4 1     1   1418 use Types::Standard qw/Str/;
  1         74214  
  1         11  
5             extends 'Throwable::Error';
6              
7             has type => (is => 'ro', isa => Str, required => 1);
8             has detail => (is => 'ro');
9              
10             sub header {
11 0     0 0   my $self = shift;
12 0           return sprintf "Exception with type: %s: %s", $self->type, $self->message;
13             }
14              
15             sub as_string {
16 0     0 1   my $self = shift;
17 0 0         if (defined $self->detail) {
18 0           return sprintf "%s\nDetail: %s", $self->header, $self->detail;
19             } else {
20 0           return $self->header;
21             }
22             }
23              
24             package Azure::AD::RemoteError;
25 1     1   801 use Moo;
  1         2  
  1         6  
26 1     1   287 use Types::Standard qw/Int/;
  1         2  
  1         4  
27             extends 'Azure::AD::Error';
28              
29             has '+type' => (default => sub { 'Remote' });
30             has status => (is => 'ro', isa => Int, required => 1);
31              
32             around header => sub {
33             my ($orig, $self) = @_;
34             my $orig_message = $self->$orig;
35             sprintf "%s with HTTP status %d", $orig_message, $self->status;
36             };
37              
38             1;