File Coverage

blib/lib/OIDC/Client/Error/Provider.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 4 4 100.0
pod n/a
total 25 25 100.0


line stmt bran cond sub pod time code
1             package OIDC::Client::Error::Provider;
2 11     11   515279 use utf8;
  11         244  
  11         107  
3 11     11   927 use Moose;
  11         612314  
  11         105  
4             extends 'OIDC::Client::Error';
5 11     11   97150 use namespace::autoclean;
  11         10810  
  11         144  
6              
7             =encoding utf8
8              
9             =head1 NAME
10              
11             OIDC::Client::Error::Provider
12              
13             =head1 DESCRIPTION
14              
15             Error class for a problem returned by the provider.
16              
17             =cut
18              
19             has '+message' => (
20             builder => '_build_message',
21             lazy => 1,
22             );
23              
24             has 'response_parameters' => (
25             is => 'ro',
26             isa => 'HashRef',
27             default => sub { {} },
28             );
29              
30             has 'alternative_error' => (
31             is => 'ro',
32             isa => 'Maybe[Str]',
33             );
34              
35             sub _build_message {
36 11     11   25 my $self = shift;
37              
38 11         23 my $params = $self->{response_parameters};
39              
40             my $message = $params->{error}
41 11   100     308 || $self->alternative_error
42             || 'OIDC: problem returned by the provider';
43              
44 11 100       56 if (my @description_keys = sort grep { $_ ne 'error' } keys %$params) {
  13         71  
45 5         15 $message .= ' (' . join(', ', map { "$_: $params->{$_}" } @description_keys) . ')';
  8         40  
46             }
47              
48 11         606 return $message;
49             }
50              
51             __PACKAGE__->meta->make_immutable;
52              
53             1;