create UnknownOutpoint exception and use it
This commit is contained in:
parent
3cd972a4da
commit
e4df0bdb5f
2 changed files with 8 additions and 2 deletions
|
@ -62,6 +62,10 @@ class UnknownURI(Exception):
|
||||||
Exception.__init__(self, 'URI {} cannot be resolved'.format(uri))
|
Exception.__init__(self, 'URI {} cannot be resolved'.format(uri))
|
||||||
self.name = uri
|
self.name = uri
|
||||||
|
|
||||||
|
class UnknownOutpoint(Exception):
|
||||||
|
def __init__(self, outpoint):
|
||||||
|
Exception.__init__(self, 'Outpoint {} cannot be resolved'.format(outpoint))
|
||||||
|
self.outpoint = outpoint
|
||||||
|
|
||||||
class InvalidName(Exception):
|
class InvalidName(Exception):
|
||||||
def __init__(self, name, invalid_characters):
|
def __init__(self, name, invalid_characters):
|
||||||
|
|
|
@ -28,7 +28,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked
|
||||||
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, IWallet
|
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, IWallet
|
||||||
from lbrynet.core.client.ClientRequest import ClientRequest
|
from lbrynet.core.client.ClientRequest import ClientRequest
|
||||||
from lbrynet.core.Error import RequestCanceledError, InsufficientFundsError, UnknownNameError
|
from lbrynet.core.Error import RequestCanceledError, InsufficientFundsError, UnknownNameError
|
||||||
from lbrynet.core.Error import UnknownClaimID, UnknownURI, NegativeFundsError
|
from lbrynet.core.Error import UnknownClaimID, UnknownURI, NegativeFundsError, UnknownOutpoint
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -772,6 +772,8 @@ class Wallet(object):
|
||||||
raise UnknownNameError(results['name'])
|
raise UnknownNameError(results['name'])
|
||||||
elif 'uri' in results:
|
elif 'uri' in results:
|
||||||
raise UnknownURI(results['uri'])
|
raise UnknownURI(results['uri'])
|
||||||
|
elif 'outpoint' in results:
|
||||||
|
raise UnknownOutpoint(results['outpoint'])
|
||||||
raise Exception(results['error'])
|
raise Exception(results['error'])
|
||||||
|
|
||||||
# case where return value is {'certificate:{'txid', 'value',...}}
|
# case where return value is {'certificate:{'txid', 'value',...}}
|
||||||
|
@ -849,7 +851,7 @@ class Wallet(object):
|
||||||
claim = yield self._get_claim_by_outpoint(txid, nout)
|
claim = yield self._get_claim_by_outpoint(txid, nout)
|
||||||
try:
|
try:
|
||||||
result = yield self._handle_claim_result(claim)
|
result = yield self._handle_claim_result(claim)
|
||||||
except (UnknownNameError, UnknownClaimID, UnknownURI) as err:
|
except (UnknownOutpoint) as err:
|
||||||
result = {'error': err.message}
|
result = {'error': err.message}
|
||||||
else:
|
else:
|
||||||
result = cached_claim
|
result = cached_claim
|
||||||
|
|
Loading…
Add table
Reference in a new issue