Skip to content

Commit

Permalink
crc
Browse files Browse the repository at this point in the history
  • Loading branch information
baiyubin2020 committed Aug 25, 2016
1 parent a6e3e99 commit fab67ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions oss2/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

OSS_CLIENT_ERROR_STATUS = -1
OSS_REQUEST_ERROR_STATUS = -2
OSS_CRC_ERROR_STATUS = -3
OSS_INCONSISTENT_ERROR_STATUS = -3

class OssError(Exception):
def __init__(self, status, headers, body, details):
Expand Down Expand Up @@ -70,9 +70,9 @@ def __str__(self):
return str(error)


class CrcError(OssError):
class InconsistentError(OssError):
def __init__(self, message):
OssError.__init__(self, OSS_CRC_ERROR_STATUS, {}, 'CrcError: ' + message, {})
OssError.__init__(self, OSS_INCONSISTENT_ERROR_STATUS, {}, 'InconsistentError: ' + message, {})

def __str__(self):
error = {'status': self.status,
Expand Down
4 changes: 2 additions & 2 deletions oss2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import crcmod

from .compat import to_string, to_bytes
from .exceptions import ClientError, CrcError
from .exceptions import ClientError, InconsistentError


_EXTRA_TYPES_MAP = {
Expand Down Expand Up @@ -221,7 +221,7 @@ def _crc_callback(crc, data):

def check_crc(operation, client_crc, oss_crc):
if client_crc != oss_crc:
raise CrcError('the crc of {0} between client and oss is not inconsistent'.format(operation))
raise InconsistentError('the crc of {0} between client and oss is not inconsistent'.format(operation))

def _invoke_crc_updater(crc_callback, __crc_calculator, content):
if crc_callback:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ def test_invalid_crc(self):

try:
self.bucket.append_object(key, 0, content, init_crc=1)
except oss2.exceptions.CrcError as e:
except oss2.exceptions.InconsistentError as e:
self.assertEqual(e.status, -3)
self.assertTrue(e.body.startswith('CrcError: the crc of'))
self.assertTrue(e.body.startswith('InconsistentError: the crc of'))
else:
self.assertTrue(False)

Expand Down

0 comments on commit fab67ab

Please sign in to comment.