forked from LBRYCommunity/lbry-sdk
add error type and message to error readme and update code
This commit is contained in:
parent
72712d6047
commit
43989122bb
4 changed files with 14 additions and 12 deletions
|
@ -53,10 +53,11 @@ Code | Name | Message
|
||||||
407 | DataDownload | Failed to download blob. *generic*
|
407 | DataDownload | Failed to download blob. *generic*
|
||||||
410 | Resolve | Failed to resolve '{url}'.
|
410 | Resolve | Failed to resolve '{url}'.
|
||||||
411 | ResolveTimeout | Failed to resolve '{url}' within the timeout.
|
411 | ResolveTimeout | Failed to resolve '{url}' within the timeout.
|
||||||
411 | ResolveCensored | Resolve of '{url}' was censored by channel with claim id '{claim_id(censor_hash)}'.
|
411 | ResolveCensored | Resolve of '{url}' was censored by channel with claim id '{censor_id}'.
|
||||||
420 | KeyFeeAboveMaxAllowed | {message}
|
420 | KeyFeeAboveMaxAllowed | {message}
|
||||||
421 | InvalidPassword | Password is invalid.
|
421 | InvalidPassword | Password is invalid.
|
||||||
422 | IncompatibleWalletServer | '{server}:{port}' has an incompatibly old version.
|
422 | IncompatibleWalletServer | '{server}:{port}' has an incompatibly old version.
|
||||||
|
423 | TooManyClaimSearchParameters | {key} cant be set for more than {limit} items.
|
||||||
431 | ServerPaymentInvalidAddress | Invalid address from wallet server: '{address}' - skipping payment round.
|
431 | ServerPaymentInvalidAddress | Invalid address from wallet server: '{address}' - skipping payment round.
|
||||||
432 | ServerPaymentWalletLocked | Cannot spend funds with locked wallet, skipping payment round.
|
432 | ServerPaymentWalletLocked | Cannot spend funds with locked wallet, skipping payment round.
|
||||||
433 | ServerPaymentFeeAboveMaxAllowed | Daily server fee of {daily_fee} exceeds maximum configured of {max_fee} LBC.
|
433 | ServerPaymentFeeAboveMaxAllowed | Daily server fee of {daily_fee} exceeds maximum configured of {max_fee} LBC.
|
||||||
|
|
|
@ -234,13 +234,6 @@ class InvalidPasswordError(WalletError):
|
||||||
super().__init__("Password is invalid.")
|
super().__init__("Password is invalid.")
|
||||||
|
|
||||||
|
|
||||||
class TooManyClaimSearchParameters(WalletError):
|
|
||||||
|
|
||||||
def __init__(self, key, limit):
|
|
||||||
self.key = key
|
|
||||||
super().__init__(f"{key} cant be set for more than {limit} items.")
|
|
||||||
|
|
||||||
|
|
||||||
class IncompatibleWalletServerError(WalletError):
|
class IncompatibleWalletServerError(WalletError):
|
||||||
|
|
||||||
def __init__(self, server, port):
|
def __init__(self, server, port):
|
||||||
|
@ -249,6 +242,14 @@ class IncompatibleWalletServerError(WalletError):
|
||||||
super().__init__(f"'{server}:{port}' has an incompatibly old version.")
|
super().__init__(f"'{server}:{port}' has an incompatibly old version.")
|
||||||
|
|
||||||
|
|
||||||
|
class TooManyClaimSearchParametersError(WalletError):
|
||||||
|
|
||||||
|
def __init__(self, key, limit):
|
||||||
|
self.key = key
|
||||||
|
self.limit = limit
|
||||||
|
super().__init__(f"{key} cant be set for more than {limit} items.")
|
||||||
|
|
||||||
|
|
||||||
class ServerPaymentInvalidAddressError(WalletError):
|
class ServerPaymentInvalidAddressError(WalletError):
|
||||||
|
|
||||||
def __init__(self, address):
|
def __init__(self, address):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from elasticsearch import AsyncElasticsearch, NotFoundError, ConnectionError
|
||||||
from elasticsearch.helpers import async_streaming_bulk
|
from elasticsearch.helpers import async_streaming_bulk
|
||||||
|
|
||||||
from lbry.crypto.base58 import Base58
|
from lbry.crypto.base58 import Base58
|
||||||
from lbry.error import ResolveCensoredError, TooManyClaimSearchParameters
|
from lbry.error import ResolveCensoredError, TooManyClaimSearchParametersError
|
||||||
from lbry.schema.result import Outputs, Censor
|
from lbry.schema.result import Outputs, Censor
|
||||||
from lbry.schema.tags import clean_tags
|
from lbry.schema.tags import clean_tags
|
||||||
from lbry.schema.url import URL, normalize_name
|
from lbry.schema.url import URL, normalize_name
|
||||||
|
@ -466,7 +466,7 @@ def expand_query(**kwargs):
|
||||||
key = key.replace('claim.', '')
|
key = key.replace('claim.', '')
|
||||||
many = key.endswith('__in') or isinstance(value, list)
|
many = key.endswith('__in') or isinstance(value, list)
|
||||||
if many and len(value) > 2048:
|
if many and len(value) > 2048:
|
||||||
raise TooManyClaimSearchParameters(key, 2048)
|
raise TooManyClaimSearchParametersError(key, 2048)
|
||||||
if many:
|
if many:
|
||||||
key = key.replace('__in', '')
|
key = key.replace('__in', '')
|
||||||
value = list(filter(None, value))
|
value = list(filter(None, value))
|
||||||
|
|
|
@ -21,7 +21,7 @@ from elasticsearch import ConnectionTimeout
|
||||||
from prometheus_client import Counter, Info, Histogram, Gauge
|
from prometheus_client import Counter, Info, Histogram, Gauge
|
||||||
|
|
||||||
import lbry
|
import lbry
|
||||||
from lbry.error import TooManyClaimSearchParameters
|
from lbry.error import TooManyClaimSearchParametersError
|
||||||
from lbry.build_info import BUILD, COMMIT_HASH, DOCKER_TAG
|
from lbry.build_info import BUILD, COMMIT_HASH, DOCKER_TAG
|
||||||
from lbry.wallet.server.block_processor import LBRYBlockProcessor
|
from lbry.wallet.server.block_processor import LBRYBlockProcessor
|
||||||
from lbry.wallet.server.db.writer import LBRYLevelDB
|
from lbry.wallet.server.db.writer import LBRYLevelDB
|
||||||
|
@ -1029,7 +1029,7 @@ class LBRYElectrumX(SessionBase):
|
||||||
if kwargs:
|
if kwargs:
|
||||||
try:
|
try:
|
||||||
return await self.run_and_cache_query('search', kwargs)
|
return await self.run_and_cache_query('search', kwargs)
|
||||||
except TooManyClaimSearchParameters as err:
|
except TooManyClaimSearchParametersError as err:
|
||||||
self.loop.call_later(0, self.synchronous_close)
|
self.loop.call_later(0, self.synchronous_close)
|
||||||
return RPCError(1, str(err))
|
return RPCError(1, str(err))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue