@@ -189,6 +189,41 @@ keys in the dictionary should be camelCase. This is because the dictionary is pa
189189directly to the JSON-RPC request, where the keys are expected to be in camelCase.
190190
191191
192+ Changes to Exception Handling
193+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194+
195+ All Python standard library exceptions that were raised from within *web3.py * have
196+ been replaced with custom ``Web3Exception `` classes. This change allows for better
197+ control over exception handling, being able to distinguish between exceptions raised
198+ by *web3.py * and those raised from elsewhere in a codebase. The following exceptions
199+ have been replaced:
200+
201+ - ``AssertionError `` -> ``Web3AssertionError ``
202+ - ``ValueError `` -> ``Web3ValueError ``
203+ - ``TypeError `` -> ``Web3TypeError ``
204+ - ``AttributeError `` -> ``Web3AttributeError ``
205+
206+ A new ``MethodNotSupported `` exception is now raised when a method is not supported by
207+ *web3.py *. This allows a user to distinguish between when a method is not available on
208+ the current provider, ``MethodUnavailable ``, and when a method is not supported by
209+ *web3.py * under certain conditions, ``MethodNotSupported ``.
210+
211+
212+ JSON-RPC Error Handling
213+ ```````````````````````
214+
215+ Rather than a ``ValueError `` being replaced with a ``Web3ValueError `` when a JSON-RPC
216+ response comes back with an ``error `` object, a new ``Web3RPCError `` exception is
217+ now raised to provide more distinction for JSON-RPC error responses. Some previously
218+ existing exceptions now extend from this class since they too are related to JSON-RPC
219+ errors:
220+
221+ - ``MethodUnavailable ``
222+ - ``BlockNotFound ``
223+ - ``TransactionNotFound ``
224+ - ``TransactionIndexingInProgress ``
225+
226+
192227Miscellaneous Changes
193228~~~~~~~~~~~~~~~~~~~~~
194229
@@ -207,3 +242,5 @@ Miscellaneous Changes
207242 without checking if the ``geth.ipc `` file exists.
208243- ``Web3.is_address() `` returns ``True `` for non-checksummed addresses.
209244- ``Contract.encodeABI() `` has been renamed to ``Contract.encode_abi() ``.
245+ - JSON-RPC responses are now more strictly validated against the JSON-RPC 2.0
246+ specification while providing more informative error messages for invalid responses.
0 commit comments