Currently, all exceptions raised in Python are either type Exception or KeyError.
There are many areas where raising Python OOB (e.g. ValueError) exceptions or custom exceptions would be highly beneficial for SDK developers. Particularly around transaction creation and submission, RPC, etc. Accurate exceptions would provide the ability to catch and handle specific issues.
PyO3 provides two mechanisms that can help here:
- Structs for OOB Python exceptions in
pyo3::exceptions.
- The ability to define and raise custom exceptions from the bound Rust to Python. This is detailed in the Python exceptions page of the PyO3 user guide.
An (incomplete) task list:
This is breaking and should probably be handled in one body of work to the extent possible.