OpenWeatherMap/Error.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 88.8% 8 / 9 Podpod 100% 1 / 1 totaltotal 79.5% 39 / 49 CC 4 SCAR 11.0
CC
4
Cov
83%
__ANON__
6.7
__ANON__
2.0
BEGIN
1.0
CRAP 3.0
« OpenWeatherMap/Result/Forecast.pm ↑ Summary OpenWeatherMap/Result/Current.pm »
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
BranchTrueFalseTotal
$_[0] eq "api" or $_[0] eq "internal" or $_[0] eq "http" or die "Expected one of: api, internal, http" 0 1 1
Condition33%2/6
$_[0] eq "api" or $_[0] eq "internal" or $_[0] eq "http"
l!l&&r!l&&!r
010
$_[0] eq "api" or $_[0] eq "internal"
l!l&&r!l&&!r
001
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"
ABCresult
1XX1
01X1
0011
0000
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
« OpenWeatherMap/Result/Forecast.pm ↑ Summary OpenWeatherMap/Result/Current.pm »