From 327958dbe0974ca31f3c90e98c753983af781724 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Thu, 4 Jan 2018 09:33:35 -0800 Subject: [PATCH] Log error instead of asserting if writing file fails. Also remove some unused code. --- src/utils.cc | 11 +++++------ src/utils.h | 2 -- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/utils.cc b/src/utils.cc index c98658ac..ce6588b8 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -456,15 +456,14 @@ void UpdateTestExpectation(const std::string& filename, of.close(); } -void Fail(const std::string& message) { - LOG_S(FATAL) << "Fatal error: " << message; - std::exit(1); -} - void WriteToFile(const std::string& filename, const std::string& content) { std::ofstream file(filename, std::ios::out | std::ios::trunc | std::ios::binary); - assert(file.good()); + if (!file.good()) { + LOG_S(ERROR) << "Cannot write to " << filename; + return; + } + file << content; } diff --git a/src/utils.h b/src/utils.h index a1e63293..c4d991ce 100644 --- a/src/utils.h +++ b/src/utils.h @@ -99,8 +99,6 @@ void UpdateTestExpectation(const std::string& filename, const std::string& expectation, const std::string& actual); -void Fail(const std::string& message); - void WriteToFile(const std::string& filename, const std::string& content); // note: this implementation does not disable this overload for array types