| 1 | package GeoIP2::Error::IPAddressNotFound; | ||
| 2 | 2 | $GeoIP2::Error::IPAddressNotFound::VERSION = '0.050000'; | |
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | ▶ | use GeoIP2::Types qw( Str ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 2 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 2 | extends 'Throwable::Error'; | |
| 11 | |||
| 12 | 2 | has ip_address => ( | |
| 13 | is => 'ro', | ||
| 14 | isa => Str, | ||
| 15 | required => 1, | ||
| 16 | ); | ||
| 17 | |||
| 18 | 2 | 1; | |
| 19 | |||
| 20 | # ABSTRACT: An exception thrown when an IP address is not in the MaxMind GeoIP2 database | ||
| 21 | |||
| 22 | __END__ | ||
| 23 | |||
| 24 | =pod | ||
| 25 | |||
| 26 | =head1 NAME | ||
| 27 | |||
| 28 | GeoIP2::Error::IPAddressNotFound - An exception thrown when an IP address is not in the MaxMind GeoIP2 database | ||
| 29 | |||
| 30 | =head1 VERSION | ||
| 31 | |||
| 32 | version 0.050000 | ||
| 33 | |||
| 34 | =head1 SYNOPSIS | ||
| 35 | |||
| 36 | use 5.008; | ||
| 37 | |||
| 38 | use GeoIP2::WebService::Client; | ||
| 39 | use Scalar::Util qw( blessed ); | ||
| 40 | use Try::Tiny; | ||
| 41 | |||
| 42 | my $client = GeoIP2::WebService::Client->new( | ||
| 43 | user_id => 42, | ||
| 44 | license_key => 'abcdef123456', | ||
| 45 | ); | ||
| 46 | |||
| 47 | try { | ||
| 48 | $client->insights( ip => '24.24.24.24' ); | ||
| 49 | } | ||
| 50 | catch { | ||
| 51 | die $_ unless blessed $_; | ||
| 52 | if ( $_->isa('GeoIP2::Error::IPAddressNotFound') ) { | ||
| 53 | log_ip_address_not_found_error( ip_address => $_->ip_address() ); | ||
| 54 | } | ||
| 55 | |||
| 56 | # handle other exceptions | ||
| 57 | }; | ||
| 58 | |||
| 59 | =head1 DESCRIPTION | ||
| 60 | |||
| 61 | This class represents an error that occurs when an IP address is not found in | ||
| 62 | the MaxMind GeoIP2 database, either through a web service or a local database. | ||
| 63 | |||
| 64 | =head1 METHODS | ||
| 65 | |||
| 66 | The C<< $error->message() >>, and C<< $error->stack_trace() >> methods are | ||
| 67 | inherited from L<Throwable::Error>. It also provide two methods of its own: | ||
| 68 | |||
| 69 | =head2 $error->ip_address() | ||
| 70 | |||
| 71 | Returns the IP address that could not be found. | ||
| 72 | |||
| 73 | =head1 AUTHORS | ||
| 74 | |||
| 75 | =over 4 | ||
| 76 | |||
| 77 | =item * | ||
| 78 | |||
| 79 | Dave Rolsky <drolsky@maxmind.com> | ||
| 80 | |||
| 81 | =item * | ||
| 82 | |||
| 83 | Greg Oschwald <goschwald@maxmind.com> | ||
| 84 | |||
| 85 | =item * | ||
| 86 | |||
| 87 | Olaf Alders <oalders@maxmind.com> | ||
| 88 | |||
| 89 | =back | ||
| 90 | |||
| 91 | =head1 COPYRIGHT AND LICENSE | ||
| 92 | |||
| 93 | This software is copyright (c) 2014 by MaxMind, Inc.. | ||
| 94 | |||
| 95 | This is free software; you can redistribute it and/or modify it under | ||
| 96 | the same terms as the Perl 5 programming language system itself. | ||
| 97 | |||
| 98 | =cut | ||