[twitter] improve error message formatting

This commit is contained in:
Mike Fährmann
2020-07-06 23:13:05 +02:00
parent 74494b43d3
commit 6e2af9a8d8

View File

@@ -491,8 +491,16 @@ class TwitterAPI():
if response.status_code == 429:
self.extractor.wait(until=response.headers["x-rate-limit-reset"])
return self._call(endpoint, params)
try:
msg = ", ".join(
'"' + error["message"] + '"'
for error in response.json()["errors"]
)
except Exception:
msg = response.text
raise exception.StopExtraction(
"%s %s (%s)", response.status_code, response.reason, response.text)
"%s %s (%s)", response.status_code, response.reason, msg)
def _pagination(self, endpoint, params=None,
entry_tweet="tweet-", entry_cursor="cursor-bottom-"):