Update example for HTTPClient exception handling.

Eliminate the implication that HTTPError is the only
error that can be raised.  See #1168.
This commit is contained in:
Ben Darnell 2014-09-14 23:55:59 -04:00
parent 09bc9827e7
commit 24c2f57704
1 changed files with 6 additions and 1 deletions

View File

@ -63,7 +63,12 @@ class HTTPClient(object):
response = http_client.fetch("http://www.google.com/")
print response.body
except httpclient.HTTPError as e:
print "Error:", e
# HTTPError is raised for non-200 responses; the response
# can be found in e.response.
print("Error: " + str(e))
except Exception as e:
# Other errors are possible, such as IOError.
print("Error: " + str(e))
http_client.close()
"""
def __init__(self, async_client_class=None, **kwargs):