diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index 6b145b343..9e27940c5 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -737,11 +737,10 @@ std::filesystem::path makeTempPath(const std::filesystem::path & root, const std 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)