[flickr] improve error handling (#109)
This commit is contained in:
@@ -368,8 +368,15 @@ class FlickrAPI(oauth.OAuth1API):
|
|||||||
if self.api_key:
|
if self.api_key:
|
||||||
params["api_key"] = self.api_key
|
params["api_key"] = self.api_key
|
||||||
data = self.session.get(self.API_URL, params=params).json()
|
data = self.session.get(self.API_URL, params=params).json()
|
||||||
if "code" in data and data["code"] == 1:
|
if "code" in data:
|
||||||
raise exception.NotFoundError(self.subcategory)
|
if data["code"] == 1:
|
||||||
|
raise exception.NotFoundError(self.subcategory)
|
||||||
|
elif data["code"] == 98:
|
||||||
|
raise exception.AuthenticationError(data.get("message"))
|
||||||
|
elif data["code"] == 99:
|
||||||
|
raise exception.AuthorizationError()
|
||||||
|
self.log.error("API call failed: %s", data.get("message"))
|
||||||
|
raise exception.StopExtraction()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _pagination(self, method, params):
|
def _pagination(self, method, params):
|
||||||
|
|||||||
Reference in New Issue
Block a user