From 358ef4536feb43e910f515d7993d92fe7012cd0c Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 10 Sep 2021 14:30:13 -0300 Subject: [PATCH] add ConflictingInputValueError for claim_id+claim_ids --- lbry/error/README.md | 1 + lbry/error/__init__.py | 8 ++++++++ lbry/extras/daemon/daemon.py | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lbry/error/README.md b/lbry/error/README.md index ac8c689fa..8df583b36 100644 --- a/lbry/error/README.md +++ b/lbry/error/README.md @@ -34,6 +34,7 @@ Code | Name | Message **11x** | InputValue(ValueError) | Invalid argument value provided to command. 111 | GenericInputValue | The value '{value}' for argument '{argument}' is not valid. 112 | InputValueIsNone | None or null is not valid value for argument '{argument}'. +113 | ConflictingInputValue | Only '{first_argument}' or '{second_argument}' is allowed, not both. **2xx** | Configuration | Configuration errors. 201 | ConfigWrite | Cannot write configuration file '{path}'. -- When writing the default config fails on startup, such as due to permission issues. 202 | ConfigRead | Cannot find provided configuration file '{path}'. -- Can't open the config file user provided via command line args. diff --git a/lbry/error/__init__.py b/lbry/error/__init__.py index 5a26da4a0..72019868d 100644 --- a/lbry/error/__init__.py +++ b/lbry/error/__init__.py @@ -76,6 +76,14 @@ class InputValueIsNoneError(InputValueError): super().__init__(f"None or null is not valid value for argument '{argument}'.") +class ConflictingInputValueError(InputValueError): + + def __init__(self, first_argument, second_argument): + self.first_argument = first_argument + self.second_argument = second_argument + super().__init__(f"Only '{first_argument}' or '{second_argument}' is allowed, not both.") + + class ConfigurationError(BaseError): """ Configuration errors. diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index a74f14c3e..15374fa23 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -37,7 +37,8 @@ from lbry.blob_exchange.downloader import download_blob from lbry.dht.peer import make_kademlia_peer from lbry.error import ( DownloadSDTimeoutError, ComponentsNotStartedError, ComponentStartConditionNotMetError, - CommandDoesNotExistError, BaseError, WalletNotFoundError, WalletAlreadyLoadedError, WalletAlreadyExistsError + CommandDoesNotExistError, BaseError, WalletNotFoundError, WalletAlreadyLoadedError, WalletAlreadyExistsError, + ConflictingInputValueError ) from lbry.extras import system_info from lbry.extras.daemon import analytics @@ -2557,8 +2558,7 @@ class Daemon(metaclass=JSONRPCServerType): if "claim_ids" in kwargs and not kwargs["claim_ids"]: kwargs.pop("claim_ids") if {'claim_id', 'claim_ids'}.issubset(kwargs): - # TODO: use error from lbry.error - raise ValueError("Only 'claim_id' or 'claim_ids' is allowed, not both.") + raise ConflictingInputValueError('claim_id', 'claim_ids') if kwargs.pop('valid_channel_signature', False): kwargs['signature_valid'] = 1 if kwargs.pop('invalid_channel_signature', False):