Make ResumableUploadError derive from HttpError.

Fixes issue #242.

Reviewed in https://codereview.appspot.com/7415048/.
This commit is contained in:
Joe Gregorio
2013-03-01 12:27:06 -05:00
parent 954e124894
commit baf0480f41
3 changed files with 7 additions and 3 deletions

View File

@@ -93,7 +93,7 @@ class MediaUploadSizeError(Error):
pass
class ResumableUploadError(Error):
class ResumableUploadError(HttpError):
"""Error occured during resumable upload."""
pass

View File

@@ -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

View File

@@ -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."""