inst.reason isn't alway in the form (errno, strerror)
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Thu, 28 Dec 2006 01:14:12 +0100
changeset 4010 e282448d68f1
parent 4009 86098ec4b77a
child 4011 15955d84bc68
inst.reason isn't alway in the form (errno, strerror) urllib2.urlopen("foobar://foo") is an example where inst.reason is a string fix issue383
mercurial/commands.py
--- a/mercurial/commands.py	Tue Dec 26 21:59:01 2006 +0100
+++ b/mercurial/commands.py	Thu Dec 28 01:14:12 2006 +0100
@@ -3277,7 +3277,11 @@
         if hasattr(inst, "code"):
             u.warn(_("abort: %s\n") % inst)
         elif hasattr(inst, "reason"):
-            u.warn(_("abort: error: %s\n") % inst.reason[1])
+            try: # usually it is in the form (errno, strerror)
+                reason = inst.reason.args[1]
+            except: # it might be anything, for example a string
+                reason = inst.reason
+            u.warn(_("abort: error: %s\n") % reason)
         elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
             if u.debugflag:
                 u.warn(_("broken pipe\n"))