GeoIP2/Error/WebService.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 21 / 21 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« GeoIP2/Error/Type.pm ↑ Summary GeoIP2/Model/City.pm »
1 package GeoIP2::Error::WebService;
2 1 $GeoIP2::Error::WebService::VERSION = '0.050000';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use GeoIP2::Types qw( Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 with 'GeoIP2::Role::Error::HTTP';
11  
12 1 extends 'Throwable::Error';
13  
14 1 has code => (
15 is => 'ro',
16 isa => Str,
17 required => 1,
18 );
19  
20 1 1;
21  
22 # ABSTRACT: An explicit error from the GeoIP2 web service
23  
24 __END__
25  
26 =pod
27  
28 =head1 NAME
29  
30 GeoIP2::Error::WebService - An explicit error from the GeoIP2 web service
31  
32 =head1 VERSION
33  
34 version 0.050000
35  
36 =head1 SYNOPSIS
37  
38 use 5.008;
39  
40 use GeoIP2::WebService::Client;
41 use Scalar::Util qw( blessed );
42 use Try::Tiny;
43  
44 my $client = GeoIP2::WebService::Client->new(
45 user_id => 42,
46 license_key => 'abcdef123456',
47 );
48  
49 try {
50 $client->insights( ip => '24.24.24.24' );
51 }
52 catch {
53 die $_ unless blessed $_;
54 if ( $_->isa('GeoIP2::Error::HTTP') ) {
55 log_web_service_error(
56 maxmind_code => $_->code(),
57 status => $_->http_status(),
58 uri => $_->uri(),
59 );
60 }
61  
62 # handle other exceptions
63 };
64  
65 =head1 DESCRIPTION
66  
67 This class represents an error returned by MaxMind's GeoIP2 web service. It
68 extends L<Throwable::Error> and adds attributes of its own.
69  
70 =head1 METHODS
71  
72 The C<< $error->message() >>, and C<< $error->stack_trace() >> methods are
73 inherited from L<Throwable::Error>. The message will be the value provided by
74 the MaxMind web service. See L<http://dev.maxmind.com/geoip/geoip2/web-services> for
75 details.
76  
77 It also provides three methods of its own:
78  
79 =head2 $error->code()
80  
81 Returns the code returned by the MaxMind GeoIP2 web service.
82  
83 =head2 $error->http_status()
84  
85 Returns the HTTP status. This should be either a 4xx or 5xx error.
86  
87 =head2 $error->uri()
88  
89 Returns the URI which gave the HTTP error.
90  
91 =head1 AUTHORS
92  
93 =over 4
94  
95 =item *
96  
97 Dave Rolsky <drolsky@maxmind.com>
98  
99 =item *
100  
101 Greg Oschwald <goschwald@maxmind.com>
102  
103 =item *
104  
105 Olaf Alders <oalders@maxmind.com>
106  
107 =back
108  
109 =head1 COPYRIGHT AND LICENSE
110  
111 This software is copyright (c) 2014 by MaxMind, Inc..
112  
113 This is free software; you can redistribute it and/or modify it under
114 the same terms as the Perl 5 programming language system itself.
115  
116 =cut
« GeoIP2/Error/Type.pm ↑ Summary GeoIP2/Model/City.pm »