我正在构建一个助手库来调用AdWords(Google Ads)关键字规划器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
非常感谢!