test/*: catch and print all exceptions

This commit is contained in:
Max Kellermann
2018-07-17 21:56:43 +02:00
parent edb44a536a
commit d6529d8c60
24 changed files with 116 additions and 122 deletions

View File

@@ -19,7 +19,7 @@
#include "config.h"
#include "fs/io/FileOutputStream.hxx"
#include "Log.hxx"
#include "util/PrintException.hxx"
#include <unistd.h>
#include <errno.h>
@@ -49,7 +49,7 @@ Copy(OutputStream &dest, int src)
int
main(int argc, char **argv)
{
try {
if (argc != 2) {
fprintf(stderr, "Usage: WriteFile PATH\n");
return EXIT_FAILURE;
@@ -57,17 +57,15 @@ main(int argc, char **argv)
const Path path = Path::FromFS(argv[1]);
try {
FileOutputStream fos(path);
FileOutputStream fos(path);
if (!Copy(fos, STDIN_FILENO))
return EXIT_FAILURE;
fos.Commit();
return EXIT_SUCCESS;
} catch (const std::exception &e) {
LogError(e);
if (!Copy(fos, STDIN_FILENO))
return EXIT_FAILURE;
}
fos.Commit();
return EXIT_SUCCESS;
} catch (...) {
PrintException(std::current_exception());
return EXIT_FAILURE;
}