File Coverage

blib/lib/WebService/PayPal/PaymentsAdvanced/Error/HostedForm.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::PayPal::PaymentsAdvanced::Error::HostedForm;
2              
3 7     7   54 use Moo;
  7         18  
  7         49  
4              
5 7     7   2260 use namespace::autoclean;
  7         17  
  7         50  
6              
7             our $VERSION = '0.000026';
8              
9             extends 'Throwable::Error';
10              
11             with 'WebService::PayPal::PaymentsAdvanced::Error::Role::HasHTTPResponse';
12              
13             1;
14              
15             # ABSTRACT: An error message which has been parsed out of a hosted form
16              
17             __END__
18              
19             =pod
20              
21             =head1 NAME
22              
23             WebService::PayPal::PaymentsAdvanced::Error::HostedForm - An error message which has been parsed out of a hosted form
24              
25             =head1 VERSION
26              
27             version 0.000026
28              
29             =head1 SYNOPSIS
30              
31             use Try::Tiny;
32             use WebService::PayPal::PaymentsAdvanced;
33              
34             my $payments = WebService::PayPal::PaymentsAdvanced->new(...);
35             my $response = $payments->create_secure_token(...);
36              
37             my $uri;
38             try {
39             $uri = $payments->hosted_form_uri($response);
40             }
41             catch {
42             die $_ unless blessed $_;
43             if (
44             $_->isa(
45             'WebService::PayPal::PaymentsAdvanced::Error::HostedForm')
46             ) {
47             log_hosted_form_error(
48             message => $_->message,
49             response_content => $_->http_response->content,
50             );
51             }
52              
53             # handle other exceptions
54             };
55              
56             =head1 DESCRIPTION
57              
58             This class represents an error which is embedded into the HTML of a hosted
59             form. It will only be thrown if you have enabled
60             L<WebService::PayPal::PaymentsAdvanced/validate_hosted_form_uri>.
61              
62             It extends L<Throwable::Error> and adds one attribute of its own. The message
63             attribute (inherited from L<Throwable::Error>) will contain the error message
64             which was parsed out of the content of the HTML.
65              
66             =head1 METHODS
67              
68             The C<< $error->message() >>, and C<< $error->stack_trace() >> methods are
69             inherited from L<Throwable::Error>.
70              
71             =head2 http_response
72              
73             Returns the L<HTTP::Response> object which was returned when attempting to GET
74             the hosted form.
75              
76             =head2 http_status
77              
78             Returns the HTTP status code for the response.
79              
80             =head2 request_uri
81              
82             The URI of the request that caused the error.
83              
84             =head1 AUTHOR
85              
86             Olaf Alders <olaf@wundercounter.com>
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             This software is copyright (c) 2020 by MaxMind, Inc.
91              
92             This is free software; you can redistribute it and/or modify it under
93             the same terms as the Perl 5 programming language system itself.
94              
95             =cut