GeoIP2...Service(3pm)

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

πŸ’– 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>

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