From c00c0e941bfcced2f35a763e31c8a07dc8446105 Mon Sep 17 00:00:00 2001 From: Gagan Nagaraj <117705519+gagankonana@users.noreply.github.com> Date: Wed, 11 Sep 2024 07:20:22 -0700 Subject: [PATCH] Throw error when task config write is unsuccessfully (#3620) --- src/commands/CmdConfig.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index fab9b7631..543bf1432 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -95,7 +95,9 @@ bool CmdConfig::setConfigVariable(const std::string& name, const std::string& va change = true; } - if (change) File::write(Context::getContext().config.file(), contents); + if (change) + if (!File::write(Context::getContext().config.file(), contents)) + throw format("Could not write to '{1}'.", Context::getContext().config.file()); return change; } @@ -133,7 +135,9 @@ int CmdConfig::unsetConfigVariable(const std::string& name, bool confirmation /* if (!lineDeleted) line++; } - if (change) File::write(Context::getContext().config.file(), contents); + if (change) + if (!File::write(Context::getContext().config.file(), contents)) + throw format("Could not write to '{1}'.", Context::getContext().config.file()); if (change && found) return 0;