Skip to content

Commit

Permalink
add ConflictingInputValueError for claim_id+claim_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
shyba committed Sep 10, 2021
1 parent bd27aa2 commit 753a7a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions lbry/error/README.md
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions lbry/error/__init__.py
Expand Up @@ -76,6 +76,14 @@ def __init__(self, argument):
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.
Expand Down
6 changes: 3 additions & 3 deletions lbry/extras/daemon/daemon.py
Expand Up @@ -37,7 +37,8 @@
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
Expand Down Expand Up @@ -2557,8 +2558,7 @@ async def jsonrpc_claim_search(self, **kwargs):
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):
Expand Down

0 comments on commit 753a7a5

Please sign in to comment.