a3cd1272ad495d8fc8e2b8ece0bae06bdd9f09ec
[rainbowstream.git] / rainbowstream / util.py
1 import json
2
3 from twitter.util import printNicely
4 from .colors import *
5
6
7 def detail_twitter_error(twitterException):
8 """
9 Display Twitter Errors nicely
10 """
11 try:
12 loadedJson = json.loads(twitterException.response_data)
13 for m in loadedJson.get('errors', dict()):
14 info = "Error " + str(m.get('code')) + ": " + m.get('message')
15 printNicely(yellow(info))
16 except ValueError:
17 info = "Error: " + twitterException.response_data
18 printNicely(yellow(info))