rados.py: raise specific error when write is too long

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
This commit is contained in:
Josh Durgin 2011-09-20 17:24:24 -07:00
parent 9983f0762d
commit fa691dfe6c

View File

@ -47,6 +47,9 @@ class IoctxStateError(Exception):
class ObjectStateError(Exception):
pass
class LogicError(Exception):
pass
def make_ex(ret, msg):
ret = abs(ret)
if (ret == errno.EPERM):
@ -361,7 +364,7 @@ class Ioctx(object):
raise IncompleteWriteError("Wrote only %ld out of %ld bytes" % \
(ret, length))
else:
raise make_ex("Ioctx.write(%s): logic error: rados_write \
raise LogicError("Ioctx.write(%s): rados_write \
returned %d, but %d was the maximum number of bytes it could have \
written." % (self.name, ret, length))