diff --git a/dank_mids/requests.py b/dank_mids/requests.py index d5c27dfb..5c7a5b94 100644 --- a/dank_mids/requests.py +++ b/dank_mids/requests.py @@ -489,7 +489,7 @@ async def get_response(self) -> None: try: await self.spoof_response(await self.controller.make_request(self.method, self.params, request_id=self.uid)) except internal_err_types.__args__ as e: - raise DankMidsInternalError(e) + raise e if 'invalid argument' in str(e) else DankMidsInternalError(e) from e except ClientResponseError as e: if e.message == "Payload Too Large": logger.info("Payload too large. response headers: %s", e.headers) @@ -645,7 +645,7 @@ async def get_response(self) -> None: await self.spoof_response(await self.post()) # I want to see these asap when working on the lib. except internal_err_types.__args__ as e: - raise DankMidsInternalError(e) from e + raise e if 'invalid argument' in str(e) else DankMidsInternalError(e) from e except EmptyBatch as e: logger.warning("These EmptyBatch exceptions shouldn't actually happen and this except clause can probably be removed soon.") except ExceedsMaxBatchSize as e: diff --git a/dank_mids/types.py b/dank_mids/types.py index d93e75f6..825fa327 100644 --- a/dank_mids/types.py +++ b/dank_mids/types.py @@ -100,6 +100,7 @@ def exception(self) -> BadResponse: return ( PayloadTooLarge(self) if self.payload_too_large else ExceedsMaxBatchSize(self) if re.search(r'batch limit (\d+) exceeded', self.error.message) + else TypeError(self.error.message, "You're probably passing what should be an integer type as a string type. The usual culprit is a block number.") if self.error.message == 'invalid argument 1: hex string without 0x prefix' else BadResponse(self) ) diff --git a/tests/test_dank_mids.py b/tests/test_dank_mids.py index abe73772..5166cad3 100644 --- a/tests/test_dank_mids.py +++ b/tests/test_dank_mids.py @@ -1,11 +1,12 @@ +import pytest from brownie import chain -from dank_mids import instances from multicall import Call from multicall.utils import await_awaitable, gather from web3._utils.rpc_abi import RPC +from dank_mids import instances from tests.fixtures import dank_w3 CHAI = '0x06AF07097C9Eeb7fD685c692751D5C66dB49c215' @@ -64,3 +65,7 @@ def test_AttributeDict(): block = await_awaitable(dank_w3.eth.get_block("0xe25822")) assert block['timestamp'] assert block.timestamp + +def test_string_block(): + with pytest.raises(TypeError): + await_awaitable(Call(CHAI, 'totalSupply()(uint)', block_id="14000000").coroutine())