osbuild/solver: add InvalidRequestError exception

This will allow validating request arguments in the solver method in a
different way for dnf4 and dnf5 and raising an exception if needed.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-08-01 12:22:09 +02:00 committed by Simon de Vlieger
parent 33a8427dd9
commit 65ef88687e
2 changed files with 11 additions and 1 deletions

View file

@ -48,6 +48,10 @@ class DepsolveError(SolverException):
pass
class InvalidRequestError(SolverException):
pass
def modify_rootdir_path(path, root_dir):
if path and root_dir:
# if the root_dir is set, we need to translate the key path to be under this directory

View file

@ -13,7 +13,7 @@ import os.path
import sys
import tempfile
from osbuild.solver import GPGKeyReadError, MarkingError, DepsolveError, RepoError
from osbuild.solver import GPGKeyReadError, MarkingError, DepsolveError, RepoError, InvalidRequestError
# Load the solver configuration
config = {"use_dnf5": False}
@ -92,6 +92,12 @@ def solve(request, cache_dir):
"kind": "DepsolveError",
"reason": f"There was a problem depsolving {', '.join(pkgs)}: {e}"
}
except InvalidRequestError as e:
printe("error invalid request")
return None, {
"kind": "InvalidRequest",
"reason": str(e)
}
except Exception as e: # pylint: disable=broad-exception-caught
printe("error traceback")
import traceback