solver/dnf.py: fix depsolve MarkingErrors

The returned error reason didn't contain any details after the merge
with DNF4 version. The reason is that previously, the actual exception
returned by the DNF library was appended to the error reason. However,
now it is wrapped by a custom `MarkingErrors` exception, which didn't
have any details set. The wrapped exception in the `__cause__`
property was not taken into account. Revert to the original behavior
by reusing the wrapped exception message as the message for the
wrapper exception.

Extend the unit test to allow testing of depsolving failures.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-08-05 15:47:57 +02:00 committed by Tomáš Hozza
parent f19af8f374
commit cdde20385d

View file

@ -81,7 +81,7 @@ class DNF(SolverBase):
self.base.fill_sack(load_system_repo=False)
except dnf.exceptions.Error as e:
raise RepoError from e
raise RepoError(e) from e
# pylint: disable=too-many-branches
@staticmethod
@ -255,12 +255,12 @@ class DNF(SolverBase):
reponame=transaction.get("repo-ids"),
)
except dnf.exceptions.Error as e:
raise MarkingError from e
raise MarkingError(e) from e
try:
self.base.resolve()
except dnf.exceptions.Error as e:
raise DepsolveError from e
raise DepsolveError(e) from e
# store the current transaction result
last_transaction.clear()