From 5b5f261a7b3552b9bca72bdc72317af1566d243e Mon Sep 17 00:00:00 2001 From: vunhat_minh Date: Thu, 6 Aug 2015 12:31:38 +0900 Subject: [PATCH] Update TwitterException handling --- rainbowstream/util.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rainbowstream/util.py b/rainbowstream/util.py index 292a7e5..d69cf88 100644 --- a/rainbowstream/util.py +++ b/rainbowstream/util.py @@ -9,16 +9,12 @@ def detail_twitter_error(twitterException): """ Display Twitter Errors nicely """ + data = twitterException.response_data try: - # twitterException.response_data can be byte string on Python 3 - # or nornal dict on Python 2 - loadedJson = json.loads(twitterException.response_data.decode('utf8')) - for m in loadedJson.get('errors', dict()): - info = "Error " + str(m.get('code')) + ": " + m.get('message') - printNicely(yellow(info)) - except: - info = "Error: " + twitterException.response_data.decode('utf8') - printNicely(yellow(info)) + for m in data.get('errors', dict()): + printNicely(yellow(m.get('message'))) + except: + printNicely(yellow(data)) def format_prefix(listname='', keyword=''): -- 2.25.1