summaryrefslogtreecommitdiff
path: root/crawler.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-02-27 14:37:13 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-02-27 14:37:13 +0100
commit7f4850d8bf0b99d1ad94a4bc7d34d5b8949776f0 (patch)
tree2cb7b04292f0ba43ab6a145186deb967f3f7e565 /crawler.py
parente563704f337d47c1f5bbd632d053b275d443ec49 (diff)
parentb4cbe522fae1e379466b64ac8e3a06c3e45ce26a (diff)
downloadapigrabber-7f4850d8bf0b99d1ad94a4bc7d34d5b8949776f0.tar.gz
apigrabber-7f4850d8bf0b99d1ad94a4bc7d34d5b8949776f0.zip
Merge branch 'errors'
Diffstat (limited to 'crawler.py')
-rw-r--r--crawler.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/crawler.py b/crawler.py
index 7e9c862..f31c99a 100644
--- a/crawler.py
+++ b/crawler.py
@@ -7,6 +7,9 @@ import aiohttp
APIURL = "https://api.dc01.gamelockerapp.com/"
+class ApiError(Exception):
+ pass
+
class Crawler(object):
def __init__(self, token):
"""Sets constants."""
@@ -40,7 +43,10 @@ class Crawler(object):
logging.warning("rate limited, retrying")
else:
return await response.json()
- except (aiohttp.errors.ContentEncodingError):
+ except (aiohttp.errors.ContentEncodingError,
+ aiohttp.errors.ServerDisconnectedError,
+ aiohttp.errors.ClientResponseError,
+ aiohttp.errors.ClientOSError):
# API bug?
pass
await asyncio.sleep(10)
@@ -65,7 +71,7 @@ class Crawler(object):
if "errors" in res:
logging.warn("API returned error: '%s'",
res["errors"])
- break
+ raise ApiError(res["errors"])
yield res