« blib/lib/Google/Ads/AdWords/RequestStats.pm
↑ Summary
blib/lib/Google/Ads/Common/OAuth2ServiceAccountsHandler.pm »
| 1 | # Copyright 2011, Google Inc. All Rights Reserved. | ||
| 2 | # | ||
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | # you may not use this file except in compliance with the License. | ||
| 5 | # You may obtain a copy of the License at | ||
| 6 | # | ||
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | # | ||
| 9 | # Unless required by applicable law or agreed to in writing, software | ||
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | # See the License for the specific language governing permissions and | ||
| 13 | # limitations under the License. | ||
| 14 | |||
| 15 | package Google::Ads::Common::ErrorUtils; | ||
| 16 | |||
| 17 | use strict; | ||
| 18 | use version; | ||
| 19 | |||
| 20 | # The following needs to be on one line because CPAN uses a particularly hacky | ||
| 21 | # eval() to determine module versions. | ||
| 22 | use Google::Ads::Common::Constants; our $VERSION = ${Google::Ads::Common::Constants::VERSION}; | ||
| 23 | |||
| 24 | # Gets the index of the operation that was the source of an ApiError object. | ||
| 25 | sub get_source_operation_index ($) { | ||
| 26 | my ($self, $error) = @_; | ||
| 27 | if ($error->get_fieldPath() =~ /^operations\[(\d+)\]/) { | ||
| 28 | return $1; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | return 1; | ||
| 33 | |||
| 34 | =pod | ||
| 35 | |||
| 36 | =head1 NAME | ||
| 37 | |||
| 38 | Google::Ads::Common::ErrorUtils | ||
| 39 | |||
| 40 | =head1 SYNOPSIS | ||
| 41 | |||
| 42 | use Google::Ads::Common::ErrorUtils; | ||
| 43 | |||
| 44 | my $index = | ||
| 45 | Google::Ads::Common::ErrorUtils::get_source_operation_index($api_error); | ||
| 46 | |||
| 47 | # $index will contain the index of the operation that failed in the request. | ||
| 48 | |||
| 49 | =head1 DESCRIPTION | ||
| 50 | |||
| 51 | =head1 SUBROUTINES | ||
| 52 | |||
| 53 | =head2 get_source_operation_index | ||
| 54 | |||
| 55 | Gets the index of the operation that was the source of an error. | ||
| 56 | |||
| 57 | =head3 Parameters | ||
| 58 | |||
| 59 | The error of type ApiError from which the index will be retrieved. | ||
| 60 | |||
| 61 | =head3 Returns | ||
| 62 | |||
| 63 | The index of the error or nothing if an invalid error is passed. | ||
| 64 | |||
| 65 | =head1 LICENSE AND COPYRIGHT | ||
| 66 | |||
| 67 | Copyright 2011 Google Inc. | ||
| 68 | |||
| 69 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 70 | you may not use this file except in compliance with the License. | ||
| 71 | You may obtain a copy of the License at | ||
| 72 | |||
| 73 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 74 | |||
| 75 | Unless required by applicable law or agreed to in writing, software | ||
| 76 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 77 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 78 | See the License for the specific language governing permissions and | ||
| 79 | limitations under the License. | ||
| 80 | |||
| 81 | =head1 AUTHOR | ||
| 82 | |||
| 83 | David Torres E<lt>api.davidtorres at gmail.comE<gt> | ||
| 84 | |||
| 85 | =head1 REPOSITORY INFORMATION | ||
| 86 | |||
| 87 | $Rev: $ | ||
| 88 | $LastChangedBy: $ | ||
| 89 | $Id: $ | ||
| 90 | |||
| 91 | =cut |