From 8cb3453c8b7dc5f3a0a74d0722553081302fa860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20S=2E=20Ga=C3=9Fmann?= Date: Sat, 17 Feb 2024 08:16:24 +0100 Subject: [PATCH] fix: Avoid throwing erased `status-code`s --- src/vefs/vfilesystem.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vefs/vfilesystem.cpp b/src/vefs/vfilesystem.cpp index a2360ad..b3a83e6 100644 --- a/src/vefs/vfilesystem.cpp +++ b/src/vefs/vfilesystem.cpp @@ -970,6 +970,7 @@ auto vfilesystem::commit() -> result detail::lut::sector_position_of(mCommittedRoot.maximum_extent - 1)}; index_tree_layout layout(*mIndexTree, mIndexBlocks, lastAllocated); + system_error::error syncError{}; for (auto const &[path, fid] : lockedIndex) { try @@ -989,19 +990,18 @@ auto vfilesystem::commit() -> result vefs::copy(pathBytes, as_writable_bytes(std::span(descriptor.filePath))); - if (auto syncrx = layout.sync_to_tree(e, descriptor); !syncrx) + if (auto syncrx = layout.sync_to_tree(e, descriptor); + syncrx.has_failure()) { - syncrx.assume_error() - << ed::archive_file{"[archive-index]"}; + syncrx.error() << ed::archive_file{"[archive-index]"}; - // note that this isn't a child of std::exception - throw std::move(syncrx).assume_error(); + syncError = std::move(syncrx).assume_error(); } }); + if (!syncError.empty()) + { + return syncError; } - catch (system_error::error const &error) - { - return error.clone(); } catch (std::bad_alloc const &) {