1GeoIP2::Error::WebServiUcsee(r3)Contributed Perl DocumenGteaotIiPo2n::Error::WebService(3)
2
3
4
6 GeoIP2::Error::WebService - An explicit error from the GeoIP2 web
7 service
8
10 version 2.006002
11
13 use 5.008;
14
15 use GeoIP2::WebService::Client;
16 use Scalar::Util qw( blessed );
17 use Try::Tiny;
18
19 my $client = GeoIP2::WebService::Client->new(
20 account_id => 42,
21 license_key => 'abcdef123456',
22 );
23
24 try {
25 $client->insights( ip => '24.24.24.24' );
26 }
27 catch {
28 die $_ unless blessed $_;
29 if ( $_->isa('GeoIP2::Error::HTTP') ) {
30 log_web_service_error(
31 maxmind_code => $_->code(),
32 status => $_->http_status(),
33 uri => $_->uri(),
34 );
35 }
36
37 # handle other exceptions
38 };
39
41 This class represents an error returned by MaxMind's GeoIP2 web
42 service. It extends Throwable::Error and adds attributes of its own.
43
45 The "$error->message()", and "$error->stack_trace()" methods are
46 inherited from Throwable::Error. The message will be the value provided
47 by the MaxMind web service. See
48 <http://dev.maxmind.com/geoip/geoip2/web-services> for details.
49
50 It also provides three methods of its own:
51
52 $error->code()
53 Returns the code returned by the MaxMind GeoIP2 web service.
54
55 $error->http_status()
56 Returns the HTTP status. This should be either a 4xx or 5xx error.
57
58 $error->uri()
59 Returns the URI which gave the HTTP error.
60
62 Bugs may be submitted through
63 <https://github.com/maxmind/GeoIP2-perl/issues>.
64
66 • Dave Rolsky <drolsky@maxmind.com>
67
68 • Greg Oschwald <goschwald@maxmind.com>
69
70 • Mark Fowler <mfowler@maxmind.com>
71
72 • Olaf Alders <oalders@maxmind.com>
73
75 This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
76
77 This is free software; you can redistribute it and/or modify it under
78 the same terms as the Perl 5 programming language system itself.
79
80
81
82perl v5.32.1 2021-01-27 GeoIP2::Error::WebService(3)