diff --git a/osc/commands_git/pr_create.py b/osc/commands_git/pr_create.py index 11213e8d..e3435f4e 100644 --- a/osc/commands_git/pr_create.py +++ b/osc/commands_git/pr_create.py @@ -146,7 +146,7 @@ class PullRequestCreateCommand(osc.commandline_git.GitObsCommand): message = message.strip() if not message: - raise RuntimeError("Aborting operation due to empty title and description.") + raise gitea_api.GitObsRuntimeError("Aborting operation due to empty title and description.") parts = re.split(r"\n\n", message, 1) if len(parts) == 1: diff --git a/osc/gitea_api/__init__.py b/osc/gitea_api/__init__.py index f5daccff..4fbf932b 100644 --- a/osc/gitea_api/__init__.py +++ b/osc/gitea_api/__init__.py @@ -5,6 +5,7 @@ from .exceptions import BranchDoesNotExist from .exceptions import BranchExists from .exceptions import ForkExists from .exceptions import GiteaException +from .exceptions import GitObsRuntimeError from .exceptions import RepoExists from .exceptions import UserDoesNotExist from .exceptions import response_to_exception diff --git a/osc/gitea_api/common.py b/osc/gitea_api/common.py index 26b6ff4b..d448772c 100644 --- a/osc/gitea_api/common.py +++ b/osc/gitea_api/common.py @@ -60,6 +60,7 @@ class GiteaModel: def get_editor() -> List[str]: import shutil import shlex + from .exceptions import GitObsRuntimeError editor = os.getenv("EDITOR", None) if editor: @@ -80,7 +81,7 @@ def get_editor() -> List[str]: break if not editor_path: - raise RuntimeError(f"Unable to start editor '{candidates[0]}'") + raise GitObsRuntimeError(f"Unable to start editor '{candidates[0]}'") res = [editor_path] if args: diff --git a/osc/gitea_api/exceptions.py b/osc/gitea_api/exceptions.py index b520c286..95870d5c 100644 --- a/osc/gitea_api/exceptions.py +++ b/osc/gitea_api/exceptions.py @@ -61,6 +61,10 @@ class GiteaException(oscerr.OscBaseError): return result +class GitObsRuntimeError(oscerr.OscBaseError): + pass + + class MovedPermanently(GiteaException): RESPONSE_STATUS = 301 RESPONSE_MESSAGE_RE = [ diff --git a/osc/gitea_api/pr.py b/osc/gitea_api/pr.py index a1b6894c..2fe061ba 100644 --- a/osc/gitea_api/pr.py +++ b/osc/gitea_api/pr.py @@ -552,10 +552,12 @@ class PullRequest(GiteaModel): """ Approve review in a pull request. """ + from .exceptions import GitObsRuntimeError + if commit: pr_obj = cls.get(conn, owner, repo, number) if pr_obj.head_commit != commit: - raise RuntimeError("The pull request '{owner}/{repo}#{number}' has changed during the review") + raise GitObsRuntimeError("The pull request '{owner}/{repo}#{number}' has changed during the review") if reviewer: # group review bot is controlled via messages in comments