From 76dd9c392b776a2823015762814f375794120076 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 27 May 2022 11:58:09 -0400 Subject: [PATCH] fix uncaught error returning transactions that dont yet exist --- hub/common.py | 12 +++--------- hub/herald/session.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/hub/common.py b/hub/common.py index 6579d6f..fef176f 100644 --- a/hub/common.py +++ b/hub/common.py @@ -347,14 +347,9 @@ INVALID_ARGS = -32602 class CodeMessageError(Exception): - - @property - def code(self): - return self.args[0] - - @property - def message(self): - return self.args[1] + def __init__(self, code: int, message: str): + self.code = code + self.message = message def __eq__(self, other): return (isinstance(other, self.__class__) and @@ -382,7 +377,6 @@ class RPCError(CodeMessageError): pass - class DaemonError(Exception): """Raised when the daemon returns an error in its results.""" diff --git a/hub/herald/session.py b/hub/herald/session.py index 953e6a9..8400e75 100644 --- a/hub/herald/session.py +++ b/hub/herald/session.py @@ -1750,7 +1750,7 @@ class LBRYElectrumX(asyncio.Protocol): if not verbose: return raw_tx.hex() return self.coin.transaction(raw_tx).as_dict(self.coin) - return RPCError("No such mempool or blockchain transaction.") + return RPCError(BAD_REQUEST, "No such mempool or blockchain transaction.") def _get_merkle_branch(self, tx_hashes, tx_pos): """Return a merkle branch to a transaction.