From: Joel Rosdahl Date: Mon, 5 Sep 2022 11:03:43 +0000 (+0200) Subject: enhance: Improve error messages for Util::copy_file X-Git-Tag: v4.7~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bb433cb998bec97d558771107ca1a48719ec7d1;p=thirdparty%2Fccache.git enhance: Improve error messages for Util::copy_file --- diff --git a/src/Util.cpp b/src/Util.cpp index d389a40b8..c1b3651a6 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -350,7 +350,8 @@ copy_file(const std::string& src, const std::string& dest, bool via_tmp_file) { Fd src_fd(open(src.c_str(), O_RDONLY | O_BINARY)); if (!src_fd) { - throw core::Error(FMT("{}: {}", src, strerror(errno))); + throw core::Error( + FMT("Failed to open {} for reading: {}", src, strerror(errno))); } unlink(dest.c_str()); @@ -365,7 +366,8 @@ copy_file(const std::string& src, const std::string& dest, bool via_tmp_file) dest_fd = Fd(open(dest.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666)); if (!dest_fd) { - throw core::Error(FMT("{}: {}", dest, strerror(errno))); + throw core::Error( + FMT("Failed to open {} for writing: {}", dest, strerror(errno))); } }