##// 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,20 +236,20 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 util.urlerr.httperror as inst:
240 ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst))
241 except util.urlerr.urlerror as inst:
242 try: # usually it is in the form (errno, strerror)
243 reason = inst.reason.args[1]
244 except (AttributeError, IndexError):
245 # it might be anything, for example a string
246 reason = inst.reason
247 if isinstance(reason, pycompat.unicode):
248 # SSLError of Python 2.7.9 contains a unicode
249 reason = encoding.unitolocal(reason)
250 ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason))
239 except (IOError, OSError) as inst:
251 except (IOError, OSError) as inst:
240 if util.safehasattr(inst, b"code"): # HTTPError
252 if (
241 ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst))
242 elif util.safehasattr(inst, b"reason"): # URLError or SSLError
243 try: # usually it is in the form (errno, strerror)
244 reason = inst.reason.args[1]
245 except (AttributeError, IndexError):
246 # it might be anything, for example a string
247 reason = inst.reason
248 if isinstance(reason, pycompat.unicode):
249 # SSLError of Python 2.7.9 contains a unicode
250 reason = encoding.unitolocal(reason)
251 ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason))
252 elif (
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