##// END OF EJS Templates
errors: catch urllib errors specifically instead of using safehasattr()...
Martin von Zweigbergk -
r46442:ae00e170 default
parent child Browse files
Show More
@@ -236,10 +236,9 b' def callcatch(ui, func):'
236 ui.error(_(b"(did you forget to compile extensions?)\n"))
236 ui.error(_(b"(did you forget to compile extensions?)\n"))
237 elif m in b"zlib".split():
237 elif m in b"zlib".split():
238 ui.error(_(b"(is your Python install correct?)\n"))
238 ui.error(_(b"(is your Python install correct?)\n"))
239 except (IOError, OSError) as inst:
239 except util.urlerr.httperror as inst:
240 if util.safehasattr(inst, b"code"): # HTTPError
241 ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst))
240 ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst))
242 elif util.safehasattr(inst, b"reason"): # URLError or SSLError
241 except util.urlerr.urlerror as inst:
243 try: # usually it is in the form (errno, strerror)
242 try: # usually it is in the form (errno, strerror)
244 reason = inst.reason.args[1]
243 reason = inst.reason.args[1]
245 except (AttributeError, IndexError):
244 except (AttributeError, IndexError):
@@ -249,7 +248,8 b' def callcatch(ui, func):'
249 # SSLError of Python 2.7.9 contains a unicode
248 # SSLError of Python 2.7.9 contains a unicode
250 reason = encoding.unitolocal(reason)
249 reason = encoding.unitolocal(reason)
251 ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason))
250 ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason))
252 elif (
251 except (IOError, OSError) as inst:
252 if (
253 util.safehasattr(inst, b"args")
253 util.safehasattr(inst, b"args")
254 and inst.args
254 and inst.args
255 and inst.args[0] == errno.EPIPE
255 and inst.args[0] == errno.EPIPE
General Comments 0
You need to be logged in to leave comments. Login now