lib/Google/Ads/Common/ErrorUtils.pm

filter: Statementstmt 63.6% 14 / 22 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 38.0% 19 / 50 CC 8 SCAR 38.8
CC
8
Cov
36%
get_source_operation_index
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 48.3
« lib/Google/Ads/AdWords/Utilities/PageProcessor.pm ↑ Summary lib/Google/Ads/AdWords/Utilities/ReportQueryBuilder.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 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # The following needs to be on one line because CPAN uses a particularly hacky
22 # eval() to determine module versions.
23 1 ▶use Google::Ads::Common::Constants; our $VERSION = ${Google::Ads::Common::Constants::VERSION};
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # Gets the index of the operation that was the source of an ApiError object.
26 0 ▶sub get_source_operation_index ($) {
Subroutine get_source_operation_index: not called CC=8 SCAR=42.8
Pod documented
27 0 my ($self, $error) = @_;
28 0 ▶ if ($error->can('get_fieldPathElements')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($error->can('get_fieldPathElements')) { } 0 0 0
elsif ($error->get_fieldPath =~ /^operations\[(\d+)\]/) { } 0 0 0
29 0 my $field_path_elements = $error->get_fieldPathElements();
30 my $first_field_path_element =
31 0 ▶ ($field_path_elements && (scalar @{$field_path_elements} > 0))
Branch: 1 branch
BranchTrueFalseTotal
$field_path_elements && scalar @{$field_path_elements;} > 0 ? : 0 0 0
Condition0%0/3
$field_path_elements and scalar @{$field_path_elements;} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$field_path_elements and scalar @{$field_path_elements;} > 0
$field_path_elements scalar @{$field_path_elements;} > 0
Truth table0%0/3
A and B
A= $field_path_elementsB= scalar @{$field_path_elements;} > 0
ABresult
0X0
100
111
32 ? $field_path_elements->[0]
33 : undef;
34 0 ▶ if ( $first_field_path_element
Branch: 1 branch
BranchTrueFalseTotal
if ($first_field_path_element and $first_field_path_element->get_field eq "operations" and defined $first_field_path_element->get_index) 0 0 0
Condition0%0/6
$first_field_path_element and $first_field_path_element->get_field eq "operations" and defined $first_field_path_element->get_index
!ll&&!rl&&r
000
$first_field_path_element and $first_field_path_element->get_field eq "operations"
!ll&&!rl&&r
000
MC/DC0%0/3
$first_field_path_element and $first_field_path_element->get_field eq "operations" and defined $first_field_path_element->get_index
$first_field_path_element $first_field_path_element->get_field eq "operations" defined $first_field_path_element->get_index
Truth table0%0/4
A and B and C
A= $first_field_path_elementB= $first_field_path_element->get_field eq "operations"C= defined $first_field_path_element->get_index
ABCresult
0XX0
10X0
1100
1111
35 && ($first_field_path_element->get_field() eq "operations")
36 && defined $first_field_path_element->get_index())
37 {
38 0 return $first_field_path_element->get_index();
39 }
40 } elsif ($error->get_fieldPath() =~ /^operations\[(\d+)\]/) {
41 0 return $1;
42 }
43 }
44  
45 1 return 1;
46  
47 =pod
48  
49 =head1 NAME
50  
51 Google::Ads::Common::ErrorUtils
52  
53 =head1 SYNOPSIS
54  
55 use Google::Ads::Common::ErrorUtils;
56  
57 my $index =
58 Google::Ads::Common::ErrorUtils::get_source_operation_index($api_error);
59  
60 # $index will contain the index of the operation that failed in the request.
61  
62 =head1 DESCRIPTION
63  
64 =head1 SUBROUTINES
65  
66 =head2 get_source_operation_index
67  
68 Gets the index of the operation that was the source of an error.
69  
70 =head3 Parameters
71  
72 The error of type ApiError from which the index will be retrieved.
73  
74 =head3 Returns
75  
76 The index of the error or nothing if an invalid error is passed.
77  
78 =head1 LICENSE AND COPYRIGHT
79  
80 Copyright 2011 Google Inc.
81  
82 Licensed under the Apache License, Version 2.0 (the "License");
83 you may not use this file except in compliance with the License.
84 You may obtain a copy of the License at
85  
86 http://www.apache.org/licenses/LICENSE-2.0
87  
88 Unless required by applicable law or agreed to in writing, software
89 distributed under the License is distributed on an "AS IS" BASIS,
90 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91 See the License for the specific language governing permissions and
92 limitations under the License.
93  
94 =head1 REPOSITORY INFORMATION
95  
96 $Rev: $
97 $LastChangedBy: $
98 $Id: $
99  
100 =cut
« lib/Google/Ads/AdWords/Utilities/PageProcessor.pm ↑ Summary lib/Google/Ads/AdWords/Utilities/ReportQueryBuilder.pm »