From b902f9b4d48328e00d92188f432568b3b3c07391 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 5 Aug 2024 11:26:57 +0200 Subject: 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. --- src/utils/cpp/file_locking.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/utils/cpp/file_locking.cpp') 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 // for errno +#include // for errno +#include // for strerror() #ifdef __unix__ #include @@ -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; } -- cgit v1.2.3