diff options
author | Max Kellermann <max@duempel.org> | 2015-12-16 10:14:56 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-12-16 10:14:56 +0100 |
commit | 36d6ead65cf507948744ee5d8615c8ef20e42f9d (patch) | |
tree | df3a1df9600f7b76666c91521880f69d5f7db386 /test/run_gzip.cxx | |
parent | 7eae3bc8c530069e86026bf9d259e9a5ce9e4bce (diff) |
fs/io/GzipOutputStream: use C++ exceptions in constructor
Diffstat (limited to 'test/run_gzip.cxx')
-rw-r--r-- | test/run_gzip.cxx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/test/run_gzip.cxx b/test/run_gzip.cxx index 15b769f0a..af63c0991 100644 --- a/test/run_gzip.cxx +++ b/test/run_gzip.cxx @@ -20,6 +20,7 @@ #include "config.h" #include "fs/io/GzipOutputStream.hxx" #include "fs/io/StdioOutputStream.hxx" +#include "Log.hxx" #include "util/Error.hxx" #include <stdio.h> @@ -48,9 +49,8 @@ Copy(OutputStream &dest, int src, Error &error) static bool CopyGzip(OutputStream &_dest, int src, Error &error) { - GzipOutputStream dest(_dest, error); - return dest.IsDefined() && - Copy(dest, src, error) && + GzipOutputStream dest(_dest); + return Copy(dest, src, error) && dest.Flush(error); } @@ -69,11 +69,16 @@ main(int argc, gcc_unused char **argv) return EXIT_FAILURE; } - Error error; - if (!CopyGzip(stdout, STDIN_FILENO, error)) { - fprintf(stderr, "%s\n", error.GetMessage()); + try { + Error error; + if (!CopyGzip(stdout, STDIN_FILENO, error)) { + fprintf(stderr, "%s\n", error.GetMessage()); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; + } catch (const std::exception &e) { + LogError(e); return EXIT_FAILURE; } - - return EXIT_SUCCESS; } |