lbry-sdk/lbrynet/error.py

203 lines
4.1 KiB
Python
Raw Normal View History

class RPCError(Exception):
code = 0
2015-08-20 17:27:15 +02:00
class PriceDisagreementError(Exception):
pass
class DuplicateStreamHashError(Exception):
pass
2019-01-22 18:55:02 +01:00
class DownloadCancelledError(Exception):
2015-08-20 17:27:15 +02:00
pass
2017-09-27 23:23:41 +02:00
class DownloadSDTimeout(Exception):
def __init__(self, download):
super().__init__(f'Failed to download sd blob {download} within timeout')
2017-09-27 23:23:41 +02:00
self.download = download
class DownloadTimeoutError(Exception):
def __init__(self, download):
super().__init__(f'Failed to download {download} within timeout')
self.download = download
2015-08-20 17:27:15 +02:00
2017-09-27 23:23:41 +02:00
class DownloadDataTimeout(Exception):
def __init__(self, download):
super().__init__(f'Failed to download data blobs for sd hash {download} within timeout')
2017-09-27 23:23:41 +02:00
self.download = download
2019-03-31 19:42:27 +02:00
class ResolveTimeout(Exception):
def __init__(self, uri):
super().__init__(f'Failed to resolve "{uri}" within the timeout')
self.uri = uri
2015-08-20 17:27:15 +02:00
class RequestCanceledError(Exception):
pass
class NegativeFundsError(Exception):
pass
class NullFundsError(Exception):
pass
class InsufficientFundsError(RPCError):
code = -310
2015-08-20 17:27:15 +02:00
class CurrencyConversionError(Exception):
pass
class FileOpenError(ValueError):
# this extends ValueError because it is replacing a ValueError in EncryptedFileDownloader
# and I don't know where it might get caught upstream
pass
class ResolveError(Exception):
pass
2015-08-20 17:27:15 +02:00
class ConnectionClosedBeforeResponseError(Exception):
pass
class KeyFeeAboveMaxAllowed(Exception):
pass
2017-02-28 02:18:57 +01:00
class InvalidExchangeRateResponse(Exception):
def __init__(self, source, reason):
super().__init__(f'Failed to get exchange rate from {source}:{reason}')
2017-02-28 02:18:57 +01:00
self.source = source
self.reason = reason
2015-08-20 17:27:15 +02:00
class UnknownNameError(Exception):
def __init__(self, name):
super().__init__(f'Name {name} is unknown')
2015-08-20 17:27:15 +02:00
self.name = name
2017-06-09 19:39:55 +02:00
class UnknownClaimID(Exception):
def __init__(self, claim_id):
super().__init__(f'Claim {claim_id} is unknown')
2017-06-09 19:39:55 +02:00
self.claim_id = claim_id
class UnknownURI(Exception):
def __init__(self, uri):
super().__init__(f'URI {uri} cannot be resolved')
2017-06-09 19:39:55 +02:00
self.name = uri
class UnknownOutpoint(Exception):
def __init__(self, outpoint):
super().__init__(f'Outpoint {outpoint} cannot be resolved')
self.outpoint = outpoint
2017-06-09 19:39:55 +02:00
class InvalidName(Exception):
def __init__(self, name, invalid_characters):
2016-07-29 00:48:29 +02:00
self.name = name
self.invalid_characters = invalid_characters
super().__init__(
'URI contains invalid characters: {}'.format(','.join(invalid_characters)))
2016-07-29 00:48:29 +02:00
class UnknownStreamTypeError(Exception):
def __init__(self, stream_type):
self.stream_type = stream_type
def __str__(self):
return repr(self.stream_type)
class InvalidStreamDescriptorError(Exception):
pass
2015-08-20 17:27:15 +02:00
class InvalidStreamInfoError(Exception):
def __init__(self, name, stream_info):
msg = f'{name} has claim with invalid stream info: {stream_info}'
super().__init__(msg)
2015-08-20 17:27:15 +02:00
self.name = name
self.stream_info = stream_info
2015-08-20 17:27:15 +02:00
class MisbehavingPeerError(Exception):
pass
class InvalidDataError(MisbehavingPeerError):
pass
class NoResponseError(MisbehavingPeerError):
pass
class InvalidResponseError(MisbehavingPeerError):
pass
class NoSuchBlobError(Exception):
pass
class NoSuchStreamHash(Exception):
pass
class NoSuchSDHash(Exception):
"""
Raised if sd hash is not known
"""
class InvalidBlobHashError(Exception):
pass
class InvalidHeaderError(Exception):
pass
class InvalidAuthenticationToken(Exception):
2016-09-22 03:36:06 +02:00
pass
class NegotiationError(Exception):
pass
class InvalidCurrencyError(Exception):
def __init__(self, currency):
self.currency = currency
super().__init__(
f'Invalid currency: {currency} is not a supported currency.')
class NoSuchDirectoryError(Exception):
def __init__(self, directory):
self.directory = directory
super().__init__(f'No such directory {directory}')
class ComponentStartConditionNotMet(Exception):
pass
class ComponentsNotStarted(Exception):
pass