diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-08-05 11:26:57 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-08-05 11:36:59 +0200 |
commit | b902f9b4d48328e00d92188f432568b3b3c07391 (patch) | |
tree | 902d8fd0b91853d87ac2d2cadd7d14595a37fabf /src/utils/cpp/file_locking.cpp | |
parent | da2ebe2b5cfef7b0f2e49160aa22ef5020fa964b (diff) | |
download | justbuild-b902f9b4d48328e00d92188f432568b3b3c07391.tar.gz |
When using errno, log the actual error message
For the user it is more useful to see the actual error message,
provided by strerror(), than the pure error code.
Diffstat (limited to 'src/utils/cpp/file_locking.cpp')
-rw-r--r-- | src/utils/cpp/file_locking.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/utils/cpp/file_locking.cpp b/src/utils/cpp/file_locking.cpp index d7f0c49a..53cba2bf 100644 --- a/src/utils/cpp/file_locking.cpp +++ b/src/utils/cpp/file_locking.cpp @@ -14,7 +14,8 @@ #include "src/utils/cpp/file_locking.hpp" -#include <cerrno> // for errno +#include <cerrno> // for errno +#include <cstring> // for strerror() #ifdef __unix__ #include <sys/file.h> @@ -56,11 +57,10 @@ auto LockFile::Acquire(std::filesystem::path const& fspath, // attach flock auto err = flock(fileno(file_handle), is_shared ? LOCK_SH : LOCK_EX); if (err != 0) { - Logger::Log( - LogLevel::Error, - "LockFile: applying lock to file {} failed with errno {}", - lock_file->string(), - errno); + Logger::Log(LogLevel::Error, + "LockFile: applying lock to file {} failed with:\n{}", + lock_file->string(), + strerror(errno)); fclose(file_handle); return std::nullopt; } |