From: Lukas Pohlreich Date: Wed, 22 Oct 2014 10:17:21 +0000 (+0200) Subject: Added util function to print twitter errors X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=commitdiff_plain;h=5531923ea428470228d145d3c89fee0aecbe6e78;hp=84b41f58f96ea5feb9c571984b60d734d9037e42 Added util function to print twitter errors --- diff --git a/rainbowstream/util.py b/rainbowstream/util.py new file mode 100644 index 0000000..232845c --- /dev/null +++ b/rainbowstream/util.py @@ -0,0 +1,16 @@ +import json + +from twitter.util import printNicely + +from .colors import magenta + + +def printTwitterErrors(twitterException): + try: + loadedJson = json.loads(twitterException.response_data) + for m in loadedJson.get('errors', dict()): + printNicely( + magenta("Error " + str(m.get('code')) + ": " + m.get('message'))) + except ValueError: + printNicely( + magenta( "Error: " + twitterException.response_data))