GeoIP2...r::HTTP(3pm)

πŸ“¦
version 2.006002 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

GeoIP2::Error::HTTP β€” an HTTP transport error, bestie. that's it, that's the vibe πŸ¦‹


✨ VERSION ✨

version 2.006002 β€” yes she's specific, she's got receipts πŸ’…


🌸 SYNOPSIS 🌸

okay so here's the whole thing in action, 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_http_error(
            status => $_->http_status(),
            uri    => $_->uri(),
        );
    }

    # handle other exceptions
};

like literally just try it, and if it's an HTTP-shaped oopsie you catch it and log it. the die $_ unless blessed $_ line is doing the "is this even an object" vibe check 🫢


πŸŽ€ DESCRIPTION πŸŽ€

so this class? it represents an HTTP transport error. it extends Throwable::Error and then adds some attributes of its very own, because why be basic when you can be extra πŸ’…


πŸ‘‘ METHODS πŸ‘‘

the $error->message() and $error->stack_trace() methods are inherited from Throwable::Error β€” not her own work, she's just repping the family. but she also provides two methods of her own, and they are iconic:

πŸ’œ $error->http_status()

returns the HTTP status. and it should be either a 4xx or 5xx error. so like, either you did something wrong or they did. either way, drama. 😭

πŸ’œ $error->uri()

returns the URI which gave the HTTP error. the exact address that said "no <3" β€” she remembers everything πŸ“


🌈 SUPPORT 🌈

bugs? not the vibe, but if you found one, may be submitted through:

<https://github.com/maxmind/GeoIP2-perl/issues>

(go off, tell them everything, they wanna know πŸ’Œ)


πŸ¦‹ AUTHORS πŸ¦‹

these absolute legends made this:

  • Dave Rolsky <drolsky@maxmind.com>
  • Greg Oschwald <goschwald@maxmind.com>
  • Mark Fowler <mfowler@maxmind.com>
  • Olaf Alders <oalders@maxmind.com>

four icons, one module. main character energy all around πŸ‘‘


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. slay, open source, periodt ✨


ngl bestie, if you got a 4xx or a 5xx from an HTTP transport call, this is the girl who catches it and tells you exactly where and how bad. she's the group chat screenshot of errors. obsessed πŸ’€πŸ«Ά

perl v5.36.0 Β· 2022-11-21 β€” yeah that's the version and the date this page was blessed into existence, and that's the whole manual, no crumbs left, mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from