| 1 | # | ||||||||||||||||||||
| 2 | # This file is part of Cloudflare::API. | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||
| 5 | # | ||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 8 | # | ||||||||||||||||||||
| 9 | # Full license text is available at: | ||||||||||||||||||||
| 10 | # | ||||||||||||||||||||
| 11 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||
| 12 | # | ||||||||||||||||||||
| 13 | package Cloudflare::API::Error; | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # Compiler Pragma | ||||||||||||||||||||
| 17 | # | ||||||||||||||||||||
| 18 | 43 | ▶ | use strict qw(vars); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 43 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 43 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # External modules | ||||||||||||||||||||
| 24 | # | ||||||||||||||||||||
| 25 | 43 | ▶ | use overload '""' => 'as_string', fallback => 1; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | # Version information | ||||||||||||||||||||
| 29 | # | ||||||||||||||||||||
| 30 | 43 | $VERSION='1.011'; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | # All done. Positive return | ||||||||||||||||||||
| 34 | # | ||||||||||||||||||||
| 35 | 43 | 1; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | #============================================================================ | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 2 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 2 | my ($class, %opt)=@_; | |||||||||||||||||||
| 44 | 2 | my $self=bless(\%opt, $class); | |||||||||||||||||||
| 45 | 2 | return $self; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | sub response { return $_[0]->{'response'} } | ||||||||||||||||||
|
Subroutine
response: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 51 | 1 | ▶ | sub errors { return $_[0]->{'errors'} || [] } | ||||||||||||||||||
|
Subroutine
errors: called CC=2 SCAR=7.6
Pod
undocumented
Condition50%1/2
$_[0]{'errors'} || []
MC/DC0%0/1
$_[0]{'errors'} || []
$_[0]{'errors'}
Truth table50%1/2
A
A= $_[0]{'errors'}
| |||||||||||||||||||||
| 52 | 0 | ▶ | sub messages { return $_[0]->{'messages'} || [] } | ||||||||||||||||||
|
Subroutine
messages: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/2
$_[0]{'messages'} || []
MC/DC0%0/1
$_[0]{'messages'} || []
$_[0]{'messages'}
Truth table0%0/2
A
A= $_[0]{'messages'}
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | ▶ | sub as_string { | ||||||||||||||||||
|
Subroutine
as_string: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | # Render Cloudflare's error messages for ordinary exception output | ||||||||||||||||||||
| 59 | # | ||||||||||||||||||||
| 60 | 0 | my ($self)=@_; | |||||||||||||||||||
| 61 | 0 | my $errors_ar=$self->errors(); | |||||||||||||||||||
| 62 | 0 | ▶ | my @message=map { ref($_) eq 'HASH' ? ($_->{'message'} || '') : '' } @$errors_ar; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_->{"message"} or ""
MC/DC0%0/1
$_->{"message"} or ""
$_->{"message"}
Truth table0%0/2
A
A= $_->{"message"}
| |||||||||||||||||||||
| 63 | 0 | @message=grep { length($_) } @message; | |||||||||||||||||||
| 64 | 0 | ▶ | return @message ? join('; ', @message) : 'Cloudflare API reported failure'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||