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 85cb1d6e65..2a6998efef 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 @@ -65,11 +65,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(); + 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: + msg = str(e) if len(msg) > 0: printMessages(ui, msg.splitlines(True)) else: - ui.warn( "ERROR: scm-hook failed with error code " + str(e.getcode()) + "\n" ) + ui.warn( "ERROR: scm-hook failed with an unknown error\n" ) except ValueError: ui.warn( "scm-hook failed with an exception\n" ) return abort