diff options
Diffstat (limited to 'src/input-reader.cpp')
| -rw-r--r-- | src/input-reader.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/input-reader.cpp b/src/input-reader.cpp index 2f10530..f1df3bf 100644 --- a/src/input-reader.cpp +++ b/src/input-reader.cpp @@ -13,6 +13,12 @@ InputReader::InputReader(std::istream * stream, std::size_t block_size_bytes) : stream_(stream), block_size_bytes_(block_size_bytes) { + if (stream == nullptr) { + throw std::runtime_error("valid stream is required"); + } + if (block_size_bytes == 0) { + throw std::runtime_error("block size in bytes must be positive"); + } } SyncInputReader::SyncInputReader(std::istream * stream, std::size_t block_size_bytes) @@ -54,9 +60,6 @@ SyncInputReader::GetBuffer() AsyncInputReader::AsyncInputReader(std::istream * stream, std::size_t block_size_bytes) : InputReader(stream, block_size_bytes) { - if (block_size_bytes == 0) { - throw std::runtime_error("block size in bytes must be positive"); - } this->buffer_ = new char[block_size_bytes]; assert(this->buffer_ != nullptr); this->bytes_in_buffer_ = 0; @@ -161,4 +164,4 @@ AsyncInputReader::GetBuffer() std::vector<char> wrapper(this->buffer_, this->buffer_ + this->bytes_in_buffer_); this->bytes_in_buffer_ = 0; return wrapper; -}
\ No newline at end of file +} |
