From 7ce9b2bb4cdd9da3a0b37990bba04d74bf9b1bab Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 10 Oct 2015 00:18:42 +0100 Subject: [PATCH] [framalink] Add error handling (invalid URLs) --- modules/framalink.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/framalink.py b/modules/framalink.py index 3ed1214..1b45995 100644 --- a/modules/framalink.py +++ b/modules/framalink.py @@ -23,7 +23,12 @@ def framalink_reducer(url, data): json_data = json.loads(web.getURLContent(url, "lsturl=" + quote(data, "/:%@&=?"), header={"Content-Type": "application/x-www-form-urlencoded"})) - return json_data['short'] + if 'short' in json_data: + return json_data['short'] + elif 'msg' in json_data: + raise IRCException("Error: %s" % json_data['msg']) + else: + IRCException("An error occured while shortening %s." % data) # MODULE VARIABLES ####################################################