GeoIP2/Error/HTTP.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 20 / 20 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« GeoIP2/Error/Generic.pm ↑ Summary GeoIP2/Error/IPAddressNotFound.pm »
1 package GeoIP2::Error::HTTP;
2  
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 our $VERSION = '2.006000';
7  
8 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 with 'GeoIP2::Role::Error::HTTP';
13  
14 1 extends 'Throwable::Error';
15  
16 1 1;
17  
18 # ABSTRACT: An HTTP transport error
19  
20 __END__
21  
22 =pod
23  
24 =encoding UTF-8
25  
26 =head1 NAME
27  
28 GeoIP2::Error::HTTP - An HTTP transport error
29  
30 =head1 VERSION
31  
32 version 2.006000
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 account_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::HTTP') ) {
53 log_http_error(
54 status => $_->http_status(),
55 uri => $_->uri(),
56 );
57 }
58  
59 # handle other exceptions
60 };
61  
62 =head1 DESCRIPTION
63  
64 This class represents an HTTP transport error. It extends L<Throwable::Error>
65 and adds attributes of its own.
66  
67 =head1 METHODS
68  
69 The C<< $error->message() >>, and C<< $error->stack_trace() >> methods are
70 inherited from L<Throwable::Error>. It also provide two methods of its own:
71  
72 =head2 $error->http_status()
73  
74 Returns the HTTP status. This should be either a 4xx or 5xx error.
75  
76 =head2 $error->uri()
77  
78 Returns the URI which gave the HTTP error.
79  
80 =head1 SUPPORT
81  
82 =head1 AUTHORS
83  
84 =over 4
85  
86 =item *
87  
88 Dave Rolsky <drolsky@maxmind.com>
89  
90 =item *
91  
92 Greg Oschwald <goschwald@maxmind.com>
93  
94 =item *
95  
96 Mark Fowler <mfowler@maxmind.com>
97  
98 =item *
99  
100 Olaf Alders <oalders@maxmind.com>
101  
102 =back
103  
104 =head1 COPYRIGHT AND LICENSE
105  
106 This software is copyright (c) 2013 - 2018 by MaxMind, Inc.
107  
108 This is free software; you can redistribute it and/or modify it under
109 the same terms as the Perl 5 programming language system itself.
110  
111 =cut
« GeoIP2/Error/Generic.pm ↑ Summary GeoIP2/Error/IPAddressNotFound.pm »