summaryrefslogtreecommitdiff
path: root/src/AtomicFile.cpp
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-08-23 18:21:57 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-08-24 19:16:48 +0200
commita4ab84f94574a8210373cfc69a7f8e1a7f355dcf (patch)
treee0a64d271a624864d00239a93d62144f9523d104 /src/AtomicFile.cpp
parent6727cbee7a6e0d8a70bc9552be1bacb4eca929f1 (diff)
downloadccache-a4ab84f94574a8210373cfc69a7f8e1a7f355dcf.tar.gz
refactor: Use FMT macro to format exception messages
Using the FMT macro explicitly makes invalid format message constructions compile-time errors instead of run-time errors.
Diffstat (limited to 'src/AtomicFile.cpp')
-rw-r--r--src/AtomicFile.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/AtomicFile.cpp b/src/AtomicFile.cpp
index 9585df81..9d0753b4 100644
--- a/src/AtomicFile.cpp
+++ b/src/AtomicFile.cpp
@@ -23,6 +23,7 @@
#include "assertions.hpp"
#include <core/exceptions.hpp>
+#include <fmtmacros.hpp>
AtomicFile::AtomicFile(const std::string& path, Mode mode) : m_path(path)
{
@@ -45,7 +46,7 @@ AtomicFile::write(const std::string& data)
{
if (fwrite(data.data(), data.size(), 1, m_stream) != 1) {
throw core::Error(
- "failed to write data to {}: {}", m_path, strerror(errno));
+ FMT("failed to write data to {}: {}", m_path, strerror(errno)));
}
}
@@ -54,7 +55,7 @@ AtomicFile::write(const util::Blob& data)
{
if (fwrite(data.data(), data.size(), 1, m_stream) != 1) {
throw core::Error(
- "failed to write data to {}: {}", m_path, strerror(errno));
+ FMT("failed to write data to {}: {}", m_path, strerror(errno)));
}
}
@@ -67,7 +68,7 @@ AtomicFile::commit()
if (result == EOF) {
Util::unlink_tmp(m_tmp_path);
throw core::Error(
- "failed to write data to {}: {}", m_path, strerror(errno));
+ FMT("failed to write data to {}: {}", m_path, strerror(errno)));
}
Util::rename(m_tmp_path, m_path);
}