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