generalize stream empty to argument empty

This commit is contained in:
Victor Shyba 2021-09-17 01:20:24 -03:00
parent 00a850500d
commit e569fdd43c
3 changed files with 10 additions and 9 deletions

View file

@ -25,7 +25,6 @@ Message | User friendly error message explaining the exceptional event. Supports
Code | Name | Message Code | Name | Message
---:|---|--- ---:|---|---
**1xx** | UserInput | User input errors. **1xx** | UserInput | User input errors.
111 | EmptyStreamName | Stream name cannot be blank.
**10x** | Command | Errors preparing to execute commands. **10x** | Command | Errors preparing to execute commands.
101 | CommandDoesNotExist | Command '{command}' does not exist. 101 | CommandDoesNotExist | Command '{command}' does not exist.
102 | CommandDeprecated | Command '{command}' is deprecated. 102 | CommandDeprecated | Command '{command}' is deprecated.
@ -36,6 +35,7 @@ Code | Name | Message
111 | GenericInputValue | The value '{value}' for argument '{argument}' is not valid. 111 | GenericInputValue | The value '{value}' for argument '{argument}' is not valid.
112 | InputValueIsNone | None or null is not valid value for argument '{argument}'. 112 | InputValueIsNone | None or null is not valid value for argument '{argument}'.
113 | ConflictingInputValue | Only '{first_argument}' or '{second_argument}' is allowed, not both. 113 | ConflictingInputValue | Only '{first_argument}' or '{second_argument}' is allowed, not both.
114 | InputStringIsBlank | {argument} cannot be blank.
**2xx** | Configuration | Configuration errors. **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. 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. 202 | ConfigRead | Cannot find provided configuration file '{path}'. -- Can't open the config file user provided via command line args.

View file

@ -7,12 +7,6 @@ class UserInputError(BaseError):
""" """
class EmptyStreamNameError(UserInputError):
def __init__(self):
super().__init__("Stream name cannot be blank.")
class CommandError(UserInputError): class CommandError(UserInputError):
""" """
Errors preparing to execute commands. Errors preparing to execute commands.
@ -90,6 +84,13 @@ class ConflictingInputValueError(InputValueError):
super().__init__(f"Only '{first_argument}' or '{second_argument}' is allowed, not both.") super().__init__(f"Only '{first_argument}' or '{second_argument}' is allowed, not both.")
class InputStringIsBlankError(InputValueError):
def __init__(self, argument):
self.argument = argument
super().__init__(f"{argument} cannot be blank.")
class ConfigurationError(BaseError): class ConfigurationError(BaseError):
""" """
Configuration errors. Configuration errors.

View file

@ -38,7 +38,7 @@ from lbry.dht.peer import make_kademlia_peer
from lbry.error import ( from lbry.error import (
DownloadSDTimeoutError, ComponentsNotStartedError, ComponentStartConditionNotMetError, DownloadSDTimeoutError, ComponentsNotStartedError, ComponentStartConditionNotMetError,
CommandDoesNotExistError, BaseError, WalletNotFoundError, WalletAlreadyLoadedError, WalletAlreadyExistsError, CommandDoesNotExistError, BaseError, WalletNotFoundError, WalletAlreadyLoadedError, WalletAlreadyExistsError,
ConflictingInputValueError, AlreadyPurchasedError, PrivateKeyNotFoundError, EmptyStreamNameError ConflictingInputValueError, AlreadyPurchasedError, PrivateKeyNotFoundError, InputStringIsBlankError
) )
from lbry.extras import system_info from lbry.extras import system_info
from lbry.extras.daemon import analytics from lbry.extras.daemon import analytics
@ -5242,7 +5242,7 @@ class Daemon(metaclass=JSONRPCServerType):
def valid_stream_name_or_error(name: str): def valid_stream_name_or_error(name: str):
try: try:
if not name: if not name:
raise EmptyStreamNameError() raise InputStringIsBlankError('Stream name')
parsed = URL.parse(name) parsed = URL.parse(name)
if parsed.has_channel: if parsed.has_channel:
# TODO: use error from lbry.error # TODO: use error from lbry.error