need to use ValueError to account for different json libraries throwing different exceptions
This commit is contained in:
parent
fa2122127c
commit
1e627f9fb1
1 changed files with 2 additions and 2 deletions
|
|
@ -175,7 +175,7 @@ class Twython(EndpointsMixin, object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = response.json()
|
content = response.json()
|
||||||
except json.JSONDecodeError:
|
except ValueError:
|
||||||
raise TwythonError('Response was not valid JSON. Unable to decode.')
|
raise TwythonError('Response was not valid JSON. Unable to decode.')
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
@ -188,7 +188,7 @@ class Twython(EndpointsMixin, object):
|
||||||
content = response.json()
|
content = response.json()
|
||||||
# {"errors":[{"code":34,"message":"Sorry, that page does not exist"}]}
|
# {"errors":[{"code":34,"message":"Sorry, that page does not exist"}]}
|
||||||
error_message = content['errors'][0]['message']
|
error_message = content['errors'][0]['message']
|
||||||
except json.JSONDecodeError:
|
except ValueError:
|
||||||
# bad json data from Twitter for an error
|
# bad json data from Twitter for an error
|
||||||
pass
|
pass
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue