]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
enhance: Improve error messages for Util::copy_file
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 5 Sep 2022 11:03:43 +0000 (13:03 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 6 Sep 2022 06:13:28 +0000 (08:13 +0200)
src/Util.cpp

index d389a40b81cd362c3b2b9063fe5f3cd1518f3775..c1b3651a669295a730b7ad88e17f88ba405d97c4 100644 (file)
@@ -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)));
     }
   }