line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GeoIP2::Error::WebService; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.006002'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
255
|
use GeoIP2::Types qw( Str ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use namespace::clean -except => 'meta'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'GeoIP2::Role::Error::HTTP'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
extends 'Throwable::Error'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has code => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => Str, |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# ABSTRACT: An explicit error from the GeoIP2 web service |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__END__ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding UTF-8 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
GeoIP2::Error::WebService - An explicit error from the GeoIP2 web service |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 VERSION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
version 2.006002 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use 5.008; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use GeoIP2::WebService::Client; |
47
|
|
|
|
|
|
|
use Scalar::Util qw( blessed ); |
48
|
|
|
|
|
|
|
use Try::Tiny; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $client = GeoIP2::WebService::Client->new( |
51
|
|
|
|
|
|
|
account_id => 42, |
52
|
|
|
|
|
|
|
license_key => 'abcdef123456', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
try { |
56
|
|
|
|
|
|
|
$client->insights( ip => '24.24.24.24' ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
catch { |
59
|
|
|
|
|
|
|
die $_ unless blessed $_; |
60
|
|
|
|
|
|
|
if ( $_->isa('GeoIP2::Error::HTTP') ) { |
61
|
|
|
|
|
|
|
log_web_service_error( |
62
|
|
|
|
|
|
|
maxmind_code => $_->code(), |
63
|
|
|
|
|
|
|
status => $_->http_status(), |
64
|
|
|
|
|
|
|
uri => $_->uri(), |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# handle other exceptions |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This class represents an error returned by MaxMind's GeoIP2 web service. It |
74
|
|
|
|
|
|
|
extends L<Throwable::Error> and adds attributes of its own. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The C<< $error->message() >>, and C<< $error->stack_trace() >> methods are |
79
|
|
|
|
|
|
|
inherited from L<Throwable::Error>. The message will be the value provided by |
80
|
|
|
|
|
|
|
the MaxMind web service. See L<http://dev.maxmind.com/geoip/geoip2/web-services> for |
81
|
|
|
|
|
|
|
details. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
It also provides three methods of its own: |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 $error->code() |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns the code returned by the MaxMind GeoIP2 web service. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 $error->http_status() |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns the HTTP status. This should be either a 4xx or 5xx error. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 $error->uri() |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns the URI which gave the HTTP error. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SUPPORT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/GeoIP2-perl/issues>. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHORS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Dave Rolsky <drolsky@maxmind.com> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Greg Oschwald <goschwald@maxmind.com> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Mark Fowler <mfowler@maxmind.com> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Olaf Alders <oalders@maxmind.com> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This software is copyright (c) 2013 - 2019 by MaxMind, Inc. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
128
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |