normalise_rpc_error

Documentation for eth_defi.provider.rpcdb.normalise_rpc_error function.

normalise_rpc_error(error)

Convert heterogeneous provider failures to stable aggregation values.

JSON-RPC response dictionaries use their numeric error code. HTTP failures use http_<status>. Other Python failures use the concrete exception class name. The provider’s original error message is retained.

Parameters

error (Union[BaseException, dict[str, Any]]) – A JSON-RPC error dictionary or an exception raised by the provider.

Returns

(error_code, error_message) suitable for RPCRequestStats.record_error().

Return type

tuple[str, str]