AdWords RateExceededError

AdWords RateExceededError

我正在构建一个帮助程序库来调用 AdWords(Google 广告)关键字规划器 API 并且在出现 RateExceededError 错误时遇到问题。

我收到的具体错误消息如下。

GoogleAdsServerFault: RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30, errorDetails="Quota check failed: QuotaInfo{quotaGroupId=v2-kwi-webapi-global, userId=global}"> Original AdsAPI trace for debugging [
com.google.ads.api.services.common.error.ApiException: RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30, errorDetails="Quota check failed: QuotaInfo{quotaGroupId=v2-kwi-webapi-global, userId=global}">
Underlying ApiErrors are: 
    RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30>

我目前正在使用以下设置调用 API 并捕获错误,但偶尔仍会引发异常。有没有更好的方法来捕获这些错误并将异常记录为警告?

class AdwordsAPIException(Exception):
  pass

def call_adwords_api_client(self, selector):
  try:
    return _adwords_client.get(selector)
  except AdwordsAPIException:
    return None

非常感谢!

好吧,您创建了一个从未引发的自定义异常 class,要跳过所有异常,试试这个

def call_adwords_api_client(self, selector):
  try:
    return _adwords_client.get(selector)
  except:
    return None

此外,api 建议等待 30 秒后再重试。祝你好运。