From baf0480f414d79cca31d9d02a64967e72fa3dfd2 Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Fri, 1 Mar 2013 12:27:06 -0500 Subject: [PATCH] Make ResumableUploadError derive from HttpError. Fixes issue #242. Reviewed in https://codereview.appspot.com/7415048/. --- apiclient/errors.py | 2 +- apiclient/http.py | 2 +- tests/test_discovery.py | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) 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 @@ class MediaUploadSizeError(Error): 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 @@ class HttpRequest(object): 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 @@ class Discovery(unittest.TestCase): '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."""