input/InputStream: migrate from class Error to C++ exceptions

This commit is contained in:
Max Kellermann
2016-09-09 18:47:42 +02:00
parent 597e59f10d
commit 8c744efd56
64 changed files with 440 additions and 473 deletions

View File

@@ -20,10 +20,11 @@
#include "config.h"
#include "TextInputStream.hxx"
#include "InputStream.hxx"
#include "util/Error.hxx"
#include "util/TextFile.hxx"
#include "Log.hxx"
#include <stdexcept>
#include <assert.h>
TextInputStream::TextInputStream(InputStreamPtr &&_is)
@@ -58,12 +59,12 @@ TextInputStream::ReadLine()
character */
--dest.size;
Error error;
size_t nbytes = is->LockRead(dest.data, dest.size, error);
if (nbytes > 0)
buffer.Append(nbytes);
else if (error.IsDefined()) {
LogError(error);
size_t nbytes;
try {
nbytes = is->LockRead(dest.data, dest.size);
} catch (const std::runtime_error &e) {
LogError(e);
return nullptr;
}