From 2bb433cb998bec97d558771107ca1a48719ec7d1 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Mon, 5 Sep 2022 13:03:43 +0200 Subject: [PATCH] enhance: Improve error messages for Util::copy_file --- src/Util.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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))); } } -- 2.47.2