File Coverage

blib/lib/WebService/MinFraud/Error/HTTP.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package WebService::MinFraud::Error::HTTP;
2              
3 1     1   8 use Moo;
  1         2  
  1         7  
4 1     1   330 use namespace::autoclean;
  1         2  
  1         9  
5              
6             our $VERSION = '1.009001';
7              
8             with 'WebService::MinFraud::Role::Error::HTTP';
9              
10             extends 'Throwable::Error';
11              
12             1;
13              
14             # ABSTRACT: An HTTP transport error
15              
16             __END__
17              
18             =pod
19              
20             =encoding UTF-8
21              
22             =head1 NAME
23              
24             WebService::MinFraud::Error::HTTP - An HTTP transport error
25              
26             =head1 VERSION
27              
28             version 1.009001
29              
30             =head1 SYNOPSIS
31              
32             use 5.010;
33              
34             use WebService::MinFraud::Client;
35              
36             use Scalar::Util qw( blessed );
37             use Try::Tiny;
38              
39             my $client = WebService::MinFraud::Client->new(
40             account_id => 42,
41             license_key => 'abcdef123456',
42             );
43              
44             try {
45             my $request = { device => { ip_address => '24.24.24.24' } };
46             $client->insights( $request );
47             }
48             catch {
49             die $_ unless blessed $_;
50             if ( $_->isa('WebService::MinFraud::Error::HTTP') ) {
51             log_http_error(
52             status => $_->http_status,
53             uri => $_->uri,
54             );
55             }
56              
57             # handle other exceptions
58             };
59              
60             =head1 DESCRIPTION
61              
62             This class represents an HTTP transport error. It extends L<Throwable::Error>
63             and adds attributes of its own.
64              
65             =head1 METHODS
66              
67             The C<< message >> and C<< stack_trace >> methods are
68             inherited from L<Throwable::Error>. It also provide two methods of its own:
69              
70             =head2 http_status
71              
72             Returns the HTTP status. This should be either a 4xx or 5xx error.
73              
74             =head2 uri
75              
76             Returns the URI which gave the HTTP error.
77              
78             =head1 SUPPORT
79              
80             Bugs may be submitted through L<https://github.com/maxmind/minfraud-api-perl/issues>.
81              
82             =head1 AUTHOR
83              
84             Mateu Hunter <mhunter@maxmind.com>
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             This software is copyright (c) 2015 - 2019 by MaxMind, Inc.
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut