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:
parent
33a8427dd9
commit
65ef88687e
2 changed files with 11 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue