NAME
Google::Ads::GoogleAds::Utils::PartialFailureUtils
SYNOPSIS
use Google::Ads::GoogleAds::Utils::PartialFailureUtils;
while (my ($operation_index, $result) = each @{$response->{results}}) {
if (is_partial_failure_result($result)) {
my $google_ads_errors = get_google_ads_errors($operation_index,
$response->{partialFailureError});
foreach my $google_ads_error (@$google_ads_errors) {
printf "Operation %d failed with error: %s.\n", $operation_index,
$google_ads_error->{message};
}
} else {
printf "Operation %d succeeded.\n", $operation_index;
}
}
DESCRIPTION
This module contains utility methods for handling partial failure of operations.
METHODS
is_partial_failure_result
Checks if a result in a mutate response is a partial failure.
Parameters
result: a result hash in a mutate response.
Returns
True, if the result is a partial failure. False, otherwise.
get_google_ads_errors
Returns a list of Google::Ads::GoogleAds::V17::Errors::GoogleAdsError instances for a given operation index.
Parameters
operation_index: the index of the operation, starting from 0.
partial_failure_error: the partialFailureError hash in the mutate response, with the detail list containing Google::Ads::GoogleAds::V17::Errors::GoogleAdsFailure instances.
Returns
An array containing the Google::Ads::GoogleAds::V17::Errors::GoogleAdsError instances for the given operation index.
get_google_ads_failure
Extracts the Google::Ads::GoogleAds::V17::Errors::GoogleAdsFailure instance from a partial failure detail.
Parameters
detail: an element in the details hash in the mutate response.
Returns
A Google::Ads::GoogleAds::V17::Errors::GoogleAdsFailure object or undef if not found.
__get_google_ads_errors
The private method to extract a list of Google::Ads::GoogleAds::V17::Errors::GoogleAdsError instances from a Google::Ads::GoogleAds::V17::Errors::GoogleAdsFailure instance for a given operation index.
Parameters
operation_index: the index of the operation, starting from 0.
google_ads_failure: the Google::Ads::GoogleAds::V17::Errors::GoogleAdsFailure instance.
Returns
An array containing the Google::Ads::GoogleAds::V17::Errors::GoogleAdsError instances from the Google::Ads::GoogleAds::V17::Errors::GoogleAdsFailure instance for the given operation index.
LICENSE AND COPYRIGHT
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
REPOSITORY INFORMATION
$Rev: $
$LastChangedBy: $
$Id: $