[MERGE] Correct handling of error if http_proxy can't be resolved
John Arbash Meinel
john at arbash-meinel.com
Sun Oct 8 01:11:09 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Matthieu Moy wrote:
> Hi,
>
> Following is an attempt of correct error in pycurl in the case where
> http_proxy can't be resolved (it happens to me on my laptop when I
> forget to unset the proxy I have to use at work, and I get an ugly
> backtrace).
>
> I'm not 100% sure I did the right thing, so here's what lead to my
> modifications:
>
> First obvious thing was to add
> _pycurl_errors.CURLE_COULDNT_RESOLVE_PROXY to the list of errors to be
> managed by bzrlib. But then, I got the surprising error message:
>
> bzr: ERROR: Connection error: curl connection error (Success) on http://host.com/branch/.bzr/branch-format
>
> So, it seems that using curl.getinfo(pycurl.OS_ERRNO) doesn't work in
> this case, which is why I replaced it by just "e[1]". Then,
> _raise_curl_connection_error() became trivial and used only in one
> place, so I inlined it.
>
> Now, I get
>
> bzr: ERROR: Connection error: curl connection error (Couldn't resolve proxy 'myproxy.com')
> on http://host.com/branch/.bzr/branch-format
>
>
>
> ------------------------------------------------------------------------
>
> # Bazaar revision bundle v0.8
> #
> # message:
> # correct handling of proxy error
> # committer: Matthieu Moy <Matthieu.Moy at imag.fr>
> # date: Sat 2006-10-07 14:52:18.351000071 +0530
>
> === modified file bzrlib/transport/http/_pycurl.py
> --- bzrlib/transport/http/_pycurl.py
> +++ bzrlib/transport/http/_pycurl.py
> @@ -179,12 +179,6 @@
> # handle_response will raise NoSuchFile, etc based on the response code
> return code, response.handle_response(abspath, code, headers, data)
>
> - def _raise_curl_connection_error(self, curl):
> - curl_errno = curl.getinfo(pycurl.OS_ERRNO)
> - url = curl.getinfo(pycurl.EFFECTIVE_URL)
> - raise ConnectionError('curl connection error (%s) on %s'
> - % (os.strerror(curl_errno), url))
> -
> def _raise_curl_http_error(self, curl, info=None):
> code = curl.getinfo(pycurl.HTTP_CODE)
> url = curl.getinfo(pycurl.EFFECTIVE_URL)
> @@ -220,8 +214,10 @@
> mutter('got pycurl error: %s, %s, %s, url: %s ',
> e[0], _pycurl_errors.errorcode[e[0]], e, url)
> if e[0] in (_pycurl_errors.CURLE_COULDNT_RESOLVE_HOST,
> - _pycurl_errors.CURLE_COULDNT_CONNECT):
> - self._raise_curl_connection_error(curl)
> + _pycurl_errors.CURLE_COULDNT_CONNECT,
> + _pycurl_errors.CURLE_COULDNT_RESOLVE_PROXY):
> + raise ConnectionError('curl connection error (%s)\non %s'
> + % (e[1], url))
> # jam 20060713 The code didn't use to re-raise the exception here
> # but that seemed bogus
> raise
>
> === modified directory // last-changed:Matthieu.Moy at imag.fr-20061007092218-f9b
> ... 6c5b4025ca023
> # revision id: Matthieu.Moy at imag.fr-20061007092218-f9b6c5b4025ca023
> # sha1: a68cef07d47d8aa22539f3772e0451530cdf39de
> # inventory sha1: edcb34d9b74d2c4d7b8a11a3a18f86ce2d5c280b
> # parent ids:
> # pqm at pqm.ubuntu.com-20060928100633-c8c5bc2d065bfc0d
> # base id: pqm at pqm.ubuntu.com-20060928100633-c8c5bc2d065bfc0d
> # properties:
> # branch-nick: bzr.proxy-error
>
+1 from me, but I wouldn't mind getting a comment from other people.
(It also should close an open bug about Error: (Success) which we get at
other times as well).
I don't remember the exact bug number right now.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFKEIcJdeBCYSNAAMRAsF2AKCS6gfNpkj6fO/5gXB3SQ9GVBE+wACgpkMy
ZxwmRS4TTXuRmUauBBJ3p2g=
=QvEU
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list