From d0b0639d9730945398feb8d0d2a3013cb8a05c68 Mon Sep 17 00:00:00 2001 From: Ilya Baryshev Date: Mon, 25 Mar 2013 21:56:55 +0400 Subject: [PATCH] Proper exception handling Fixes #2 --- sentry_redmine/plugin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sentry_redmine/plugin.py b/sentry_redmine/plugin.py index c3c4968..0a206a5 100644 --- a/sentry_redmine/plugin.py +++ b/sentry_redmine/plugin.py @@ -109,15 +109,15 @@ class RedminePlugin(IssuePlugin): try: r = requests.post(url, data=json.dumps({'issue': payload}), headers=headers) - except requests.exceptions.HTTPError, e: - raise forms.ValidationError('Unable to reach Redmine host: %s' % (e.reason,)) + except requests.exceptions.HTTPError as e: + raise forms.ValidationError('Unable to reach Redmine host: %s' % repr(e)) try: data = json.loads(r.text) - except json.JSONDecodeError, e: + except json.JSONDecodeError as e: #print >> sys.stderr, "ERROR: %s" % e #print >> sys.stderr, "RESP:", r.text - raise forms.ValidationError('Unable to reach Redmine host: %s' % (e.reason,)) + raise forms.ValidationError('Unable to reach Redmine host: %s' % repr(e)) if not 'issue' in data or not 'id' in data['issue']: raise forms.ValidationError('Unable to create redmine ticket')