From e1667c6e39bb6c1e6c89a17b2dcd8dc97d4836f2 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Thu, 8 Aug 2013 15:49:42 +0200 Subject: [PATCH 1/2] use str(e) if e.read() and e.conn is not available on scmhooks.py --- .../main/resources/sonia/scm/python/scmhooks.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/scmhooks.py b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/scmhooks.py index 8e4184a269..04723ed9d6 100644 --- a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/scmhooks.py +++ b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/scmhooks.py @@ -59,11 +59,18 @@ def callHookUrl(ui, repo, hooktype, node): else: ui.warn( "ERROR: scm-hook failed with error code " + str(conn.code) + "\n" ) except urllib2.URLError, e: - msg = e.read(); - if len(msg) > 0: - ui.warn( "ERROR: " + msg) + msg = None + # some URLErrors have no read method + if hasattr(e, "read"): + msg = e.read() + elif hasattr(e, "code"): + msg = "scm-hook failed with error code " + str(e.code) + "\n" else: - ui.warn( "ERROR: scm-hook failed with error code " + str(e.getcode()) + "\n" ) + msg = str(e) + if len(msg) > 0: + ui.warn( "ERROR: " + msg ) + else: + ui.warn( "ERROR: scm-hook failed with an unknown error\n" ) except ValueError: ui.warn( "scm-hook failed with an exception\n" ) return abort From 20a6704a27b310a0708d1bfa7727abef99f1217f Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 9 Aug 2013 11:09:02 +0200 Subject: [PATCH 2/2] close branch issue-424