diff --git a/lbry/error/README.md b/lbry/error/README.md index 5de36d3e5..4c70813d9 100644 --- a/lbry/error/README.md +++ b/lbry/error/README.md @@ -52,6 +52,7 @@ Code | Name | Message 405 | ChannelKeyNotFound | Channel signing key not found. 406 | ChannelKeyInvalid | Channel signing key is out of date. -- For example, channel was updated but you don't have the updated key. 407 | DataDownload | Failed to download blob. *generic* +408 | PrivateKeyNotFound | Couldn't find private key for {key} '{value}'. 410 | Resolve | Failed to resolve '{url}'. 411 | ResolveTimeout | Failed to resolve '{url}' within the timeout. 411 | ResolveCensored | Resolve of '{url}' was censored by channel with claim id '{censor_id}'. diff --git a/lbry/error/__init__.py b/lbry/error/__init__.py index 944b22c65..db56fbe06 100644 --- a/lbry/error/__init__.py +++ b/lbry/error/__init__.py @@ -207,6 +207,14 @@ class DataDownloadError(WalletError): super().__init__("Failed to download blob. *generic*") +class PrivateKeyNotFoundError(WalletError): + + def __init__(self, key, value): + self.key = key + self.value = value + super().__init__(f"Couldn't find private key for {key} '{value}'.") + + class ResolveError(WalletError): def __init__(self, url): diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index f6a349f09..d87b402c6 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -38,7 +38,7 @@ from lbry.dht.peer import make_kademlia_peer from lbry.error import ( DownloadSDTimeoutError, ComponentsNotStartedError, ComponentStartConditionNotMetError, CommandDoesNotExistError, BaseError, WalletNotFoundError, WalletAlreadyLoadedError, WalletAlreadyExistsError, - ConflictingInputValueError, AlreadyPurchasedError + ConflictingInputValueError, AlreadyPurchasedError, PrivateKeyNotFoundError ) from lbry.extras import system_info from lbry.extras.daemon import analytics @@ -5333,7 +5333,7 @@ class Daemon(metaclass=JSONRPCServerType): if len(channels) == 1: if for_signing and not channels[0].has_private_key: # TODO: use error from lbry.error - raise Exception(f"Couldn't find private key for {key} '{value}'. ") + raise PrivateKeyNotFoundError(key, value) return channels[0] elif len(channels) > 1: # TODO: use error from lbry.error