Make ResumableUploadError derive from HttpError.
Fixes issue #242.
Reviewed in https://codereview.appspot.com/7415048/.
diff --git a/apiclient/errors.py b/apiclient/errors.py
index c3d35bc..2bf9149 100644
--- a/apiclient/errors.py
+++ b/apiclient/errors.py
@@ -93,7 +93,7 @@
pass
-class ResumableUploadError(Error):
+class ResumableUploadError(HttpError):
"""Error occured during resumable upload."""
pass
diff --git a/apiclient/http.py b/apiclient/http.py
index bfb7f77..a956477 100644
--- a/apiclient/http.py
+++ b/apiclient/http.py
@@ -744,7 +744,7 @@
if resp.status == 200 and 'location' in resp:
self.resumable_uri = resp['location']
else:
- raise ResumableUploadError("Failed to retrieve starting URI.")
+ raise ResumableUploadError(resp, content)
elif self._in_error_state:
# If we are in an error state then query the server for current state of
# the upload by sending an empty PUT and reading the 'range' header in
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index ac6f97c..92213ac 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -769,7 +769,11 @@
'location': 'http://upload.example.com'}, ''),
])
- self.assertRaises(ResumableUploadError, request.execute, http=http)
+ try:
+ request.execute(http=http)
+ self.fail('Should have raised ResumableUploadError.')
+ except ResumableUploadError, e:
+ self.assertEqual(400, e.resp.status)
def test_resumable_media_fail_unknown_response_code_subsequent_request(self):
"""Not a multipart upload."""