Enhanced HttpError to now include the original request URI if possible.
diff --git a/apiclient/discovery.py b/apiclient/discovery.py
index 0c4c854..cc31967 100644
--- a/apiclient/discovery.py
+++ b/apiclient/discovery.py
@@ -39,6 +39,7 @@
 from model import JsonModel
 from errors import UnknownLinkType
 from errors import HttpError
+from errors import InvalidJsonError
 
 URITEMPLATE = re.compile('{[^}]*}')
 VARNAME = re.compile('[a-zA-Z0-9_-]+')
@@ -108,10 +109,12 @@
   requested_url = uritemplate.expand(discoveryServiceUrl, params)
   logging.info('URL being requested: %s' % requested_url)
   resp, content = http.request(requested_url)
+  if resp.status > 400:
+    raise HttpError(resp, content, requested_url)
   try:
     service = simplejson.loads(content)
   except ValueError, e:
-    raise HttpError(resp, content)
+    raise InvalidJsonError()
 
   fn = os.path.join(os.path.dirname(__file__), 'contrib',
       serviceName, 'future.json')
diff --git a/apiclient/errors.py b/apiclient/errors.py
index 054629b..0d81ec3 100644
--- a/apiclient/errors.py
+++ b/apiclient/errors.py
@@ -22,9 +22,10 @@
 class HttpError(Error):
   """HTTP data was invalid or unexpected."""
 
-  def __init__(self, resp, content):
+  def __init__(self, resp, content, uri=None):
     self.resp = resp
     self.content = content
+    self.uri = uri
 
   def _get_reason(self):
     """Calculate the reason for the error from the response content.
@@ -40,11 +41,20 @@
     return reason
 
   def __repr__(self):
-    return '<HttpError %s "%s">' % (self.resp.status, self._get_reason())
+    if self.uri:
+      return '<HttpError %s when requesting %s returned "%s">' % (
+          self.resp.status, self.uri, self._get_reason())
+    else:
+      return '<HttpError %s "%s">' % (self.resp.status, self._get_reason())
 
   __str__ = __repr__
 
 
+class InvalidJsonError(Error):
+  """The JSON returned could not be parsed."""
+  pass
+
+
 class UnknownLinkType(Error):
   """Link type unknown or unexpected."""
   pass
diff --git a/apiclient/http.py b/apiclient/http.py
index 094271f..2132390 100644
--- a/apiclient/http.py
+++ b/apiclient/http.py
@@ -16,6 +16,7 @@
 import os
 
 from model import JsonModel
+from errors import HttpError
 
 
 class HttpRequest(object):
@@ -67,6 +68,9 @@
     resp, content = http.request(self.uri, self.method,
                                       body=self.body,
                                       headers=self.headers)
+
+    if resp.status >= 300:
+      raise HttpError(resp, content, self.uri)
     return self.postproc(resp, content)