Make blob upload errors more specific

This commit is contained in:
Joseph Schorr 2018-10-29 12:21:18 -04:00
parent d18a7935e1
commit 88f19ee0b9
2 changed files with 10 additions and 3 deletions

View file

@ -24,6 +24,9 @@ BLOB_CONTENT_TYPE = 'application/octet-stream'
class BlobUploadException(Exception):
""" Base for all exceptions raised when uploading blobs. """
class BlobRangeMismatchException(BlobUploadException):
""" Exception raised if the range to be uploaded does not match. """
class BlobDigestMismatchException(BlobUploadException):
""" Exception raised if the digest requested does not match that of the contents uploaded. """
@ -134,7 +137,7 @@ class _BlobUploadManager(object):
if start_offset > 0 and start_offset > self.blob_upload.byte_count:
logger.error('start_offset provided greater than blob_upload.byte_count')
raise BlobUploadException()
raise BlobRangeMismatchException()
# Ensure that we won't go over the allowed maximum size for blobs.
max_blob_size = bitmath.parse_string_unsafe(self.settings.maximum_blob_size)