| 1 | package Weather::OpenWeatherMap::Error; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Weather::OpenWeatherMap::Error::VERSION = '0.005001'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Types::Standard -all; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | with 'StackTrace::Auto'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | use overload | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | bool => sub { 1 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | '""' => sub { shift->as_string }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | fallback => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | has request => ( | |||||||||||||||||||||||||||||||||||||||||
| 18 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | isa => InstanceOf['Weather::OpenWeatherMap::Request'], | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | has source => ( | ||||||||||||||||||||||||||||||||||||||||||
| 24 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | isa => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | $_[0] eq 'api' || $_[0] eq 'internal' || $_[0] eq 'http' | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=19.1
Branch: 1 branch
Condition33%2/6
$_[0] eq "api" or $_[0] eq "internal" or $_[0] eq "http"
$_[0] eq "api" or $_[0] eq "internal"
MC/DC0%0/3
$_[0] eq "api" or $_[0] eq "internal" or $_[0] eq "http"
$_[0] eq "api"
$_[0] eq "internal"
$_[0] eq "http"
Truth table25%1/4
A or B or C
A= $_[0] eq "api"B= $_[0] eq "internal"C= $_[0] eq "http"
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | or die "Expected one of: api, internal, http" | ||||||||||||||||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | has status => ( | |||||||||||||||||||||||||||||||||||||||||
| 33 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my $src = uc $self->source; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my $msg = $self->status; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | "($src) $msg" | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | Weather::OpenWeatherMap::Error - Internal and API error objects | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # Usually received from Weather::OpenWeatherMap | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | These objects contain information on internal or backend (API) errors; they | ||||||||||||||||||||||||||||||||||||||||||
| 60 | are generally thrown by L<Weather::OpenWeatherMap> or emitted by | ||||||||||||||||||||||||||||||||||||||||||
| 61 | L<POEx::Weather::OpenWeatherMap> in response to a failed request. | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | These objects overload stringification (see L</as_string>). | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | These objects consume L<StackTrace::Auto>. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | =head2 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =head3 request | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | The original L<Weather::OpenWeatherMap::Request> object that caused the | ||||||||||||||||||||||||||||||||||||||||||
| 72 | error to occur. | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | =head3 source | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | The source of the error, one of: C<api>, C<internal>, C<http> | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | =head3 status | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | The error/status message string. | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | =head2 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | =head3 as_string | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | Returns a stringified representation of the error in the form: | ||||||||||||||||||||||||||||||||||||||||||
| 87 | C<< (uc $err->source) $err->status >> | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | L<Weather::OpenWeatherMap> | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | L<StackTrace::Auto> | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | L<Devel::StackTrace> | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | Jon Portnoy <avenj@cobaltirc.org> | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||||||||||||||||