From: Joel Rosdahl Date: Sat, 25 Jan 2020 10:19:52 +0000 (+0100) Subject: Make failure to write a stats file a soft error (#516) X-Git-Tag: v4.0~667 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d03a09209f0aa89190ca2e19825fd40efd2d5f9;p=thirdparty%2Fccache.git Make failure to write a stats file a soft error (#516) If a stats file update for some reason fails, the exception will bubble up to ccache_main which just prints the error and exits with an error. Let’s consider such failures non-fatal and just log them. --- diff --git a/src/stats.cpp b/src/stats.cpp index 4a3da04d9..02ce7aeb3 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -230,7 +230,13 @@ stats_write(const char* path, struct counters* counters) for (size_t i = 0; i < counters->size; ++i) { file.write(fmt::format("{}\n", counters->data[i])); } - file.commit(); + try { + file.commit(); + } catch (const Error& e) { + // Make failure to write a stats file a soft error since it's not important + // enough to fail whole the process. + cc_log("Error: %s", e.what()); + } } static void