line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2019, Google LLC |
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
|
|
|
|
|
|
|
# The class represents the exception message from Google Ads API server. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use strict; |
19
|
5
|
|
|
5
|
|
944
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
125
|
|
20
|
5
|
|
|
5
|
|
22
|
use version; |
|
5
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
135
|
|
21
|
5
|
|
|
5
|
|
80
|
|
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
24
|
|
22
|
|
|
|
|
|
|
# The following needs to be on one line because CPAN uses a particularly hacky |
23
|
|
|
|
|
|
|
# eval() to determine module versions. |
24
|
|
|
|
|
|
|
use Google::Ads::GoogleAds::Constants; our $VERSION = ${Google::Ads::GoogleAds::Constants::VERSION}; |
25
|
5
|
|
|
5
|
|
318
|
|
|
5
|
|
|
|
|
59
|
|
|
5
|
|
|
|
|
209
|
|
26
|
|
|
|
|
|
|
use Class::Std::Fast constructor => 'none'; |
27
|
5
|
|
|
5
|
|
25
|
|
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
33
|
|
28
|
|
|
|
|
|
|
# Class::Std-style attributes. Most values are read from googleads.properties file. |
29
|
|
|
|
|
|
|
# These need to go in the same line for older Perl interpreters to understand. |
30
|
|
|
|
|
|
|
my %code_of : ATTR(:get<code> :default<>); |
31
|
|
|
|
|
|
|
my %message_of : ATTR(:get<message> :default<>); |
32
|
|
|
|
|
|
|
my %status_of : ATTR(:get<status> :default<>); |
33
|
|
|
|
|
|
|
my %details_of : ATTR(:get<details> :default<>); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $self = bless \do { my $exception = Class::Std::Fast::ID }, shift; |
36
|
|
|
|
|
|
|
my $ident = ident $self; |
37
|
3
|
|
|
3
|
0
|
5290
|
|
|
3
|
|
|
|
|
11
|
|
38
|
3
|
|
|
|
|
19
|
my $response_body = shift; |
39
|
|
|
|
|
|
|
my $error = $response_body->{error}; |
40
|
3
|
|
|
|
|
17
|
|
41
|
3
|
|
|
|
|
6
|
$code_of{$ident} = $error->{code}; |
42
|
|
|
|
|
|
|
$message_of{$ident} = $error->{message}; |
43
|
3
|
|
|
|
|
9
|
$status_of{$ident} = $error->{status}; |
44
|
3
|
|
|
|
|
6
|
|
45
|
3
|
|
|
|
|
6
|
# The details may contain GoogleAdsFailure or standard GRPC errors, e.g. |
46
|
|
|
|
|
|
|
# BadRequest, PreconditionFailure, QuotaFailure. |
47
|
|
|
|
|
|
|
$details_of{$ident} = $error->{details}; |
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
6
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
3
|
|
|
|
|
15
|
|
52
|
|
|
|
|
|
|
# Extracts the GoogleAdsFailure object from the details hash. |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
foreach my $detail (@{$self->get_details}) { |
56
|
3
|
|
|
3
|
1
|
6002
|
my $type = $detail->{"\@type"}; |
57
|
|
|
|
|
|
|
if ($type =~ /google.ads.googleads.v(\d+).errors.GoogleAdsFailure/) { |
58
|
3
|
|
|
|
|
5
|
my $class = |
|
3
|
|
|
|
|
13
|
|
59
|
3
|
|
|
|
|
20
|
sprintf( |
60
|
3
|
100
|
|
|
|
62
|
Google::Ads::GoogleAds::Constants::GOOGLE_ADS_FAILURE_CLASS_NAME, |
61
|
2
|
|
|
|
|
14
|
$1); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Require class name. |
64
|
|
|
|
|
|
|
eval("require $class"); |
65
|
|
|
|
|
|
|
return $class->new({errors => $detail->{errors}}); |
66
|
|
|
|
|
|
|
} |
67
|
2
|
|
|
|
|
96
|
} |
68
|
2
|
|
|
|
|
19
|
return undef; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
11
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=pod |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Google::Ads::GoogleAds::GoogleAdsException |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SYNOPSIS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $api_client = Google::Ads::GoogleAds::Client->new(); |
82
|
|
|
|
|
|
|
$api_client->set_die_on_faults(0); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $response = $api_client->AdGroupAdService()->mutate($mutate_request); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
if ($response->isa("Google::Ads::GoogleAds::GoogleAdsException")) { |
87
|
|
|
|
|
|
|
my $google_ads_failure = $response->get_google_ads_failure(); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Do something with the GoogleAdsFailure object. |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The class represents the exception message from Google Ads API server. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
There is a get_ method associated with each attribute for retrieving them dynamically. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 code |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The HTTP response code. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 message |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
A human-readable description of this exception. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 status |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The status code of this exception. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 details |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
The detailed information of this exception, which may contain failure messages. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 METHODS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 get_google_ads_failure |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Extracts a L<Google::Ads::GoogleAds::V11::Errors::GoogleAdsFailure> object from the |
121
|
|
|
|
|
|
|
L</details> attribute of the current exception object. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head3 Returns |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
A L<Google::Ads::GoogleAds::V11::Errors::GoogleAdsFailure> object or undef if not found. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright 2019 Google LLC |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
132
|
|
|
|
|
|
|
you may not use this file except in compliance with the License. |
133
|
|
|
|
|
|
|
You may obtain a copy of the License at |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software |
138
|
|
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
139
|
|
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
140
|
|
|
|
|
|
|
See the License for the specific language governing permissions and |
141
|
|
|
|
|
|
|
limitations under the License. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 REPOSITORY INFORMATION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
$Rev: $ |
146
|
|
|
|
|
|
|
$LastChangedBy: $ |
147
|
|
|
|
|
|
|
$Id: $ |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |