From c51bf8d6e06296295c61b379c6e7751ddd543dcb Mon Sep 17 00:00:00 2001 From: BobTheBuidler Date: Sun, 5 Jun 2022 23:48:57 +0000 Subject: [PATCH] fix: exception handling when e.args[0] is a RequestInfo object --- dank_mids/controller.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dank_mids/controller.py b/dank_mids/controller.py index 7c3b6b01..8c47b8d6 100644 --- a/dank_mids/controller.py +++ b/dank_mids/controller.py @@ -7,6 +7,7 @@ from typing import Any, Dict, List, Literal, Optional, Union import multicall +from aiohttp import RequestInfo from eth_utils import to_checksum_address from hexbytes import HexBytes from multicall.utils import gather, run_in_subprocess @@ -31,12 +32,14 @@ def reattempt_call_and_return_exception(target: str, calldata: bytes, block: str def _err_msg(e: Exception) -> str: """ Extract an error message from `e` to use in a spoof rpc response. """ - if isinstance(e.args[0], str): + if isinstance(e.args[0], str) or isinstance(e.args[0], RequestInfo): err_msg = f"DankMidsError: {type(e)} {e.args}" elif "message" in e.args[0]: err_msg = e.args[0]["message"] elif "error" in e.args[0] and "message" in e.args[0]["error"]: err_msg = e.args[0]["error"]["message"] + else: + raise e return err_msg