verbose multiarchitectureerror

This commit is contained in:
Evgenii Alekseev 2023-09-05 18:06:48 +03:00
parent e514740032
commit f22c10c70d
2 changed files with 9 additions and 3 deletions

View File

@ -96,7 +96,7 @@ class Handler:
# actually we do not have to spawn another process if it is single-process application, do we?
if len(repositories) > 1:
if not cls.ALLOW_MULTI_ARCHITECTURE_RUN:
raise MultipleArchitecturesError(args.command)
raise MultipleArchitecturesError(args.command, repositories)
with Pool(len(repositories)) as pool:
result = pool.starmap(cls.call, [(args, repository_id) for repository_id in repositories])

View File

@ -23,6 +23,8 @@ from collections.abc import Callable
from pathlib import Path
from typing import Any, Self
from ahriman.models.repository_id import RepositoryId
class BuildError(RuntimeError):
"""
@ -173,14 +175,18 @@ class MultipleArchitecturesError(ValueError):
exception which will be raised if multiple architectures are not supported by the handler
"""
def __init__(self, command: str) -> None:
def __init__(self, command: str, repositories: list[RepositoryId] | None = None) -> None:
"""
default constructor
Args:
command(str): command name which throws exception
repositories(list[RepositoryId] | None, optional): found repository list (Default value = None)
"""
ValueError.__init__(self, f"Multiple architectures/repositories are not supported by subcommand {command}")
message = f"Multiple architectures/repositories are not supported by subcommand {command}"
if repositories is not None:
message += f", got {repositories}"
ValueError.__init__(self, message)
class OptionError(ValueError):