GeoIP2...Service(3pm)
π GeoIP2::Error::WebService β the vibe check on your web service errors π
okay so bestie, this page shows up in your man as GeoIP2...Service(3pm) (truncated, iconic, we move) from the User Contributed Perl Documentation. It's all about GeoIP2::Error::WebService. Sit down, grab a strawberry drink π, we're doing error handling and it's gonna be cute.
β¨ NAME β¨
GeoIP2::Error::WebService β an explicit error from the GeoIP2 web service. Like, the error isn't hiding, it's telling you exactly what went down. main character energy fr.
πΈ VERSION πΈ
version 2.006002
π¦ SYNOPSIS π¦
here's the whole thing verbatim, no cap:
use 5.008;
use GeoIP2::WebService::Client;
use Scalar::Util qw( blessed );
use Try::Tiny;
my $client = GeoIP2::WebService::Client->new(
account_id => 42,
license_key => 'abcdef123456',
);
try {
$client->insights( ip => '24.24.24.24' );
}
catch {
die $_ unless blessed $_;
if ( $_->isa('GeoIP2::Error::HTTP') ) {
log_web_service_error(
maxmind_code => $_->code(),
status => $_->http_status(),
uri => $_->uri(),
);
}
# handle other exceptions
};
see how we're catching the error, checking it's blessed, then asking if it's a GeoIP2::Error::HTTP before pulling the code(), http_status() and uri() out of it? that's the whole point. π
π DESCRIPTION π
So this class represents an error that got returned by MaxMind's GeoIP2 web service. It extends Throwable::Error and then adds attributes of its own on top. not me inheriting AND customizing, we love a class with range. β¨
π METHODS π
the $error->message() and $error->stack_trace() methods? those are inherited from Throwable::Error. and the message will literally be the value that the MaxMind web service handed you. for the deets, go look at <http://dev.maxmind.com/geoip/geoip2/web-services>. iykyk.
It also provides three methods of its own. yes, three. we counted. π«Ά
π $error->code()
Returns the code returned by the MaxMind GeoIP2 web service.
π $error->http_status()
Returns the HTTP status. This should be either a 4xx or 5xx error. (so like, bestie, if you're seeing this, something did NOT slay.)
π $error->uri()
Returns the URI which gave the HTTP error.
π SUPPORT π
Bugs may be submitted through <https://github.com/maxmind/GeoIP2-perl/issues>. please be nice about it, the maintainers are people too π₯Ί
π§ AUTHORS π§
the literal icons who made this happen:
- Dave Rolsky <drolsky@maxmind.com>
- Greg Oschwald <goschwald@maxmind.com>
- Mark Fowler <mfowler@maxmind.com>
- Olaf Alders <oalders@maxmind.com>
β COPYRIGHT AND LICENSE β
This software is copyright (c) 2013 - 2019 by MaxMind, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free software!! we love to see it. π
ok that's the whole page, no notes, you ate that. go forth and handle your exceptions responsibly bestie π
signing off from perl v5.36.0, dated 2022-11-21, on the page they call GeoIP2...Service(3pm) β catch you in the next man page, mwah ππβ¨
π¦ where this page comes from
- debian bookworm: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms