OfflineConversionError exception handling

268 views
Skip to first unread message

Iskander Taneev

unread,
Jan 21, 2020, 7:32:14 AM1/21/20
to AdWords API and Google Ads API Forum
Hello! 

I am uploading offline conversions using googleads api. My goal is to upload records that can be uploaded and do something with the records that can't be uploaded (ex: OfflineConversionError.EXPIRED_CLICK). I am using a standard template for my 'main' function from v201809 'upload_offline_conversions.py'. Here is what I'm doing:

            try:
                main(adwords_client, conv_name, gclid, conv_dt, con_vl)
            except errors.GoogleAdsServerFault as er:
                if er.errors[0]['errorString'] == 'OfflineConversionError.EXPIRED_CLICK':
                    print('Do something')

Output that I get: 

Do something
Error summary: {'faultMessage': '[OfflineConversionError.EXPIRED_CLICK @ operations[0].operand]', 'requestId': '00059ca5009cf2710a37d718110105b0', 'serviceName': 'OfflineConversionFeedService', 'methodName': 'mutate', 'operations': '1', 'responseTime': '318'}

The code still runs, but why am I seeing 'Error summary', which can appear before or after 'Do something' statement? And how can I get rid of it?  My initial problem was trying to isolate OfflineConversionError.EXPIRED_CLICK error which I'm trying to do with 'except' statement above.

Another solution in dealing with this might be using 'client.partial_failure = True' in 'main' function. However, then I'm not sure how to 'Do something' with the clicks that fall into OfflineConversionError.EXPIRED_CLICK category, since then I'm getting 'TypeError: 'NoneType' object is not subscriptable' which comes from the     

print('Uploaded offline conversion value of "{}" for Google Click ID '
          '"{}" to "{}".'.format(new_feed[0]['conversionValue'], new_feed[0]['googleClickId'],
                                 new_feed[0]['conversionName']))

statement inside 'main' function.

The only thing that I can currently do in order to avoid 'Error summary' is to 'client.partial_failure = True' and do the following:

            try:
                main(adwords_client, conv_name, gclid, conv_dt, con_vl)

            except Exception as er:
                print(er.__dict__)
                print(er.args)
                print('Do something')

With output:
{}
("'NoneType' object is not subscriptable",)
Do something

But it doesn't fit my task of doing something with messages with different (possible) error types.

Any help would be greatly appreciated!

Regards,
Iskander


Google Ads API Forum Advisor Prod

unread,
Jan 23, 2020, 3:53:54 PM1/23/20
to adwor...@googlegroups.com

Hello,

Thank you for reaching out. From the shared details, it looks like your primary concern is to handle the conversion upload exceptions via Python client libraries using API to log more information on specific types of errors. One way to achieve this is using partial failures which allows you to handle the failed operations separately at the end. To meet your expectations, you could use the partial_failure_error field that has all the details regarding the error and implement the logic to do something based on the status code of the error. The list of GoogleAdsError objects will have the details of error code that can be used to implement your logic. Let us know if this helps.

Regards,
Nikisha Patel, Google Ads API Team



ref:_00D1U1174p._5001USwsFm:ref
Reply all
Reply to author
Forward
0 new messages