[Httplib2-discuss] httplib2 should provide custom exceptions for httplib failures
Status: Beta
Brought to you by:
jcgregorio
From: Simon W. <si...@si...> - 2006-12-07 09:52:56
|
Hi, httplib2 currently provides a number of custom exceptions, but these =20 do not cover all of the potential error conditions. For example, try =20 the following: >>> import httplib2 >>> httplib2.Http().request('http://localhost:9999/') # This server =20 is not currently running Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/willison/pythonmods/httplib2/__init__.py", line 781, =20 in request (response, content) =3D self._request(conn, authority, uri, =20 request_uri, method, body, headers, redirections, cachekey) File "/Users/willison/pythonmods/httplib2/__init__.py", line 603, =20 in _request (response, content) =3D self._conn_request(conn, request_uri, =20 method, body, headers) File "/Users/willison/pythonmods/httplib2/__init__.py", line 581, =20 in _conn_request conn.connect() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/=20 python2.5/httplib.py", line 679, in connect raise socket.error, msg socket.error: (61, 'Connection refused') >>> It would be useful if httplib2 =03caught low-level socket exceptions =20 and re-raised them as custom exceptions that are subclasses of =20 HttpLib2Error. This would allow a single "except HttpLib2Error" =20 statement to catch any errors that occurred during a request, no =20 matter if they came from httplib2, httplib or the socket module. Cheers, Simon |