change some ValueErrors to IOErrors

This commit is contained in:
Jack Robison 2017-09-15 13:46:38 -04:00
parent 421141b958
commit 8419e1e1d5
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF
3 changed files with 5 additions and 6 deletions

View file

@ -161,7 +161,7 @@ class BlobFile(object):
d = file_sender.beginFileTransfer(file_handle, reader)
d.addCallback(close_self)
else:
d = defer.fail(ValueError("Could not read the blob"))
d = defer.fail(IOError("Could not read the blob"))
return d
def writer_finished(self, writer, err=None):

View file

@ -22,9 +22,8 @@ class HashBlobWriter(object):
def write(self, data):
if self.write_handle is None:
log.info("writer has already been closed")
# can this be changed to IOError?
raise ValueError('I/O operation on closed file')
log.exception("writer has already been closed")
raise IOError('I/O operation on closed file')
self._hashsum.update(data)
self.len_so_far += len(data)

View file

@ -90,8 +90,8 @@ class BlobFileTest(unittest.TestCase):
writer.close()
yield self.assertFailure(finished_d, DownloadCanceledError)
# writes after close will throw a ValueError exception
with self.assertRaises(ValueError):
# writes after close will throw a IOError exception
with self.assertRaises(IOError):
writer.write(self.fake_content)
# another call to close will do nothing