Added exception around parsing the discovery doc.
diff --git a/apiclient/discovery.py b/apiclient/discovery.py
index 368ad3e..0c4c854 100644
--- a/apiclient/discovery.py
+++ b/apiclient/discovery.py
@@ -38,6 +38,7 @@
 from anyjson import simplejson
 from model import JsonModel
 from errors import UnknownLinkType
+from errors import HttpError
 
 URITEMPLATE = re.compile('{[^}]*}')
 VARNAME = re.compile('[a-zA-Z0-9_-]+')
@@ -107,7 +108,10 @@
   requested_url = uritemplate.expand(discoveryServiceUrl, params)
   logging.info('URL being requested: %s' % requested_url)
   resp, content = http.request(requested_url)
-  service = simplejson.loads(content)
+  try:
+    service = simplejson.loads(content)
+  except ValueError, e:
+    raise HttpError(resp, content)
 
   fn = os.path.join(os.path.dirname(__file__), 'contrib',
       serviceName, 'future.json')
diff --git a/tests/data/malformed.json b/tests/data/malformed.json
new file mode 100644
index 0000000..98232c6
--- /dev/null
+++ b/tests/data/malformed.json
@@ -0,0 +1 @@
+{
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index f682a11..e89fe9f 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -34,6 +34,7 @@
 
 from apiclient.discovery import build, key2param
 from apiclient.http import HttpMock
+from apiclient.errors import HttpError
 
 
 DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
@@ -48,6 +49,17 @@
     self.assertEqual('x007_bond', key2param('007-bond'))
 
 
+class DiscoveryErrors(unittest.TestCase):
+
+  def test_failed_to_parse_discovery_json(self):
+    self.http = HttpMock(datafile('malformed.json'), {'status': '200'})
+    try:
+      buzz = build('buzz', 'v1', self.http)
+      self.fail("should have raised an exception over malformed JSON.")
+    except HttpError, e:
+      self.assertEqual(e.content, "{\n")
+
+
 class Discovery(unittest.TestCase):
 
   def test_method_error_checking(self):