AdWords API Exception handling in Python

556 views
Skip to first unread message

Martin

unread,
Jan 16, 2014, 12:45:22 PM1/16/14
to adwor...@googlegroups.com
Hi,
I am getting the RateExceededError and according to the suggestions I want to catch this exception and respect the 'retryAfterSeconds' attribute.
However I am failing to catch just this particular exception and leaving the rest to be handled with my generic error handler.

I tried to do something like this:
try:
    working_code()
except RateExceededError as Rate_e:
    time.sleep(Rate_e.retryAfterSeconds)

but this does not work.
Is there some Exceptions import I am missing or is there another way of doing it?
Thank you!
Martin

Danial Klimkin

unread,
Jan 23, 2014, 6:03:31 AM1/23/14
to adwor...@googlegroups.com
Hello Martin,


It looks like you are excepting a wrong exception class. Let me check with the python library author to confirm.


-Danial, AdWords API Team.

Danial Klimkin

unread,
Jan 24, 2014, 4:51:18 AM1/24/14
to adwor...@googlegroups.com
Hi Martin,


Please see this example as a reference:

try:
  page = campaign_service.get(selector)
except AdWordsGoogleInternalError, e:
  inner_error = e.errors[0]
  if 'RateExceededError.RATE_EXCEEDED' == inner_error.errorString:
    // do something with inner_error.retryAfterSeconds


-Danial, AdWords API Team.


On Thursday, January 16, 2014 9:45:22 PM UTC+4, Martin wrote:
Reply all
Reply to author
Forward
0 new messages