fixed exception messages if writing to output stream fails

This commit is contained in:
Günter Obiltschnig 2019-08-23 20:55:19 +02:00
parent 0784665ce8
commit b4fd25c620
2 changed files with 22 additions and 22 deletions

View File

@ -151,7 +151,7 @@ int DeflatingStreamBuf::close()
int rc = deflate(&_zstr, Z_FINISH);
if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc));
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream");
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
while (rc != Z_STREAM_END)
@ -159,7 +159,7 @@ int DeflatingStreamBuf::close()
rc = deflate(&_zstr, Z_FINISH);
if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc));
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream");
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
}
@ -183,7 +183,7 @@ int DeflatingStreamBuf::sync()
int rc = deflate(&_zstr, Z_SYNC_FLUSH);
if (rc != Z_OK) throw IOException(zError(rc));
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream");
while (_zstr.avail_out == 0)
{
_zstr.next_out = (unsigned char*) _buffer;
@ -191,7 +191,7 @@ int DeflatingStreamBuf::sync()
rc = deflate(&_zstr, Z_SYNC_FLUSH);
if (rc != Z_OK) throw IOException(zError(rc));
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream");
};
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
@ -281,14 +281,14 @@ int DeflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length
if (_zstr.avail_out == 0)
{
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream");
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
}
if (_zstr.avail_in == 0)
{
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing deflated data to output stream");
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
break;

View File

@ -235,21 +235,21 @@ int InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length
if (rc == Z_STREAM_END)
{
_pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing inflated data to output stream");
break;
}
if (rc != Z_OK) throw IOException(zError(rc));
if (_zstr.avail_out == 0)
{
_pOstr->write(_buffer, INFLATE_BUFFER_SIZE);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing inflated data to output stream");
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = INFLATE_BUFFER_SIZE;
}
if (_zstr.avail_in == 0)
{
_pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
if (!_pOstr->good()) throw IOException("Failed writing inflated data to output stream");
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = INFLATE_BUFFER_SIZE;
break;