Skip to content

Commit

Permalink
Unify system::State::save() exceptions to FileSystemError
Browse files Browse the repository at this point in the history
The same exception can come from `utils::fs::File`.
  • Loading branch information
kontura authored and j-mracek committed Dec 15, 2023
1 parent bd55cba commit c6ca49e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libdnf5/system/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.

#include "utils/string.hpp"

#include "libdnf5/common/exception.hpp"
#include "libdnf5/utils/bgettext/bgettext-mark-domain.h"
#include "libdnf5/utils/fs/file.hpp"
#include "libdnf5/utils/fs/temp.hpp"
Expand Down Expand Up @@ -501,7 +502,11 @@ static std::string toml_format(const toml::value & value) {


void State::save() {
std::filesystem::create_directories(path);
std::error_code ec;
std::filesystem::create_directories(path, ec);
if (ec) {
throw FileSystemError(errno, path, M_("{}"), ec.message());
}

utils::fs::File(get_package_state_path(), "w").write(toml_format(make_top_value("packages", package_states)));
utils::fs::File(get_nevra_state_path(), "w").write(toml_format(make_top_value("nevras", nevra_states)));
Expand Down

0 comments on commit c6ca49e

Please sign in to comment.