From fb79e6a7a1cf8f644c88ee1947f42e822bb91bf8 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Mon, 1 Dec 2025 03:00:45 +0300 Subject: [PATCH] libutil: Propagate error code in createSymlink (cherry picked from commit bf7c53f2d3e665720c371167b8934d50e818656b) --- src/libutil/file-system.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index fba92dc8e..5cd702193 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -730,11 +730,10 @@ Path makeTempPath(const Path & root, const Path & suffix) void createSymlink(const Path & target, const Path & link) { - try { - std::filesystem::create_symlink(target, link); - } catch (std::filesystem::filesystem_error & e) { - throw SysError("creating symlink '%1%' -> '%2%'", link, target); - } + std::error_code ec; + std::filesystem::create_symlink(target, link, ec); + if (ec) + throw SysError(ec.value(), "creating symlink '%1%' -> '%2%'", link, target); } void replaceSymlink(const std::filesystem::path & target, const std::filesystem::path & link)