File Coverage

blib/lib/Ambassador/API/V2/Error.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Ambassador::API::V2::Error;
2              
3 2     2   101140 use Moo;
  2         9443  
  2         14  
4 2     2   2553 use Types::Standard ':types';
  2         632236  
  2         23  
5             with 'Ambassador::API::V2::Role::Response';
6              
7             our $VERSION = '0.001';
8              
9             use overload
10 2         18 '""' => \&as_string,
11 2     2   5636 fallback => 1;
  2         5  
12              
13             has errors => (
14             is => 'lazy',
15             isa => ArrayRef,
16             );
17              
18             sub _build_errors {
19 1     1   671 my $self = shift;
20              
21 1         4 return $self->response->{errors}{error};
22             }
23              
24             sub _code_and_message {
25 3     3   3 my $self = shift;
26              
27 3         34 return $self->code . ': ' . $self->message;
28             }
29              
30             sub as_string {
31 3     3 1 214 my $self = shift;
32              
33 3         10 return join '', map { "$_\n" } $self->_code_and_message, @{$self->errors};
  6         38  
  3         224  
34             }
35              
36             1;
37              
38             __END__