From a05b72645b7d4f08b991e95203fa388f672fb614 Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Sat, 6 Jul 2024 15:14:28 +0000 Subject: [PATCH] chore: add detail to ValidationError --- dank_mids/types.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dank_mids/types.py b/dank_mids/types.py index c73f956..49060c5 100644 --- a/dank_mids/types.py +++ b/dank_mids/types.py @@ -129,7 +129,10 @@ def decode_result(self, method: Optional[RPCEndpoint] = None, _caller = None) -> # NOTE: These must be added to the `RETURN_TYPES` constant above manually if method and (typ := RETURN_TYPES.get(method)): if method in ["eth_call", "eth_blockNumber", "eth_getCode", "eth_getBlockByNumber", "eth_getTransactionReceipt", "eth_getTransactionCount", "eth_getBalance", "eth_chainId", "erigon_getHeaderByNumber"]: - return msgspec.json.decode(self.result, type=typ) + try: + return msgspec.json.decode(self.result, type=typ) + except msgspec.ValidationError as e: + raise ValueError(e, f'method: {method} result: {msgspec.json.decode(self.result)}').with_traceback(e.__traceback__) try: start = time() decoded = msgspec.json.decode(self.result, type=typ)