Mercurial > public > mercurial-scm > hg
comparison mercurial/httprepo.py @ 2294:ce67fa312f61
Catch urllib's HTTPException and give a meaningful error message to the user.
Usually urllib only throws HTTPError exceptions, which already are a subclass
of IOError.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 16 May 2006 09:35:38 +0200 |
parents | 7761597b5da3 |
children | f77edcffb837 |
comparison
equal
deleted
inserted
replaced
2293:3dc6f2501dbc | 2294:ce67fa312f61 |
---|---|
101 self.ui.debug(_("sending %s command\n") % cmd) | 101 self.ui.debug(_("sending %s command\n") % cmd) |
102 q = {"cmd": cmd} | 102 q = {"cmd": cmd} |
103 q.update(args) | 103 q.update(args) |
104 qs = urllib.urlencode(q) | 104 qs = urllib.urlencode(q) |
105 cu = "%s?%s" % (self.url, qs) | 105 cu = "%s?%s" % (self.url, qs) |
106 resp = urllib2.urlopen(cu) | 106 try: |
107 resp = urllib2.urlopen(cu) | |
108 except httplib.HTTPException, inst: | |
109 raise IOError(None, _('http error while sending %s command') % cmd) | |
107 proto = resp.headers['content-type'] | 110 proto = resp.headers['content-type'] |
108 | 111 |
109 # accept old "text/plain" and "application/hg-changegroup" for now | 112 # accept old "text/plain" and "application/hg-changegroup" for now |
110 if not proto.startswith('application/mercurial') and \ | 113 if not proto.startswith('application/mercurial') and \ |
111 not proto.startswith('text/plain') and \ | 114 not proto.startswith('text/plain') and \ |