use str(e) if e.read() and e.conn is not available on scmhooks.py

This commit is contained in:
Sebastian Sdorra
2013-08-08 15:49:42 +02:00
parent bab3fa275d
commit e1667c6e39

View File

@@ -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