AuthorizationServer/Error.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 28 / 28 CC 2 SCAR 2.9
CC
2
Cov
100%
to_response
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« AuthorizationServer.pm ↑ Summary AuthorizationServer/Role/Store.pm »
1 package Catalyst::Plugin::OAuth2::AuthorizationServer::Error;
2 10 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 our $VERSION = '0.003';
7  
8 10 has error => ( is => 'ro', required => 1 );
9 10 has error_description => ( is => 'ro' );
10 10 has state => ( is => 'ro' );
11 10 has redirect_uri => ( is => 'ro' );
12 10 has http_status => ( is => 'ro', default => 400 );
13  
14 59 ▶sub throw ( $class, %args ) {
Subroutine throw: called CC=1 SCAR=0.0
Pod documented
15 59 die $class->new(%args);
16 }
17  
18 10 ▶sub to_response ( $self ) {
Subroutine to_response: called CC=2 SCAR=6.9
Pod documented
19 10 my %body = ( error => $self->error );
20 10 ▶ $body{error_description} = $self->error_description
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->error_description 9 1 10
21 if defined $self->error_description;
22 10 return ( \%body, $self->http_status );
23 }
24  
25 =head1 NAME
26  
27 Catalyst::Plugin::OAuth2::AuthorizationServer::Error - a structured OAuth error
28  
29 =head1 DESCRIPTION
30  
31 Thrown by the engine and the plugin to signal an OAuth error. Attributes:
32 C<error> (required, the RFC error code string), C<error_description>
33 (optional), C<state> and C<redirect_uri> (optional, used by the authorize
34 redirect-on-error path, RFC 6749 4.1.2.1, not the JSON body), C<http_status>
35 (default 400). C<to_response> returns C<< (\%body, $status) >> for direct
36 rendering; the body carries only C<error> + C<error_description>.
37  
38 =head1 METHODS
39  
40 =head2 throw( error => $code, ... )
41  
42 Construct and C<die> a new instance.
43  
44 =head2 to_response
45  
46 Return the RFC envelope hashref and the HTTP status.
47  
48 =cut
49  
50 10 1;
« AuthorizationServer.pm ↑ Summary AuthorizationServer/Role/Store.pm »