Description
Is your feature request related to a problem? Please describe.
When ingesting raw plutus data in some form, if the structure is complicated the error messages can be unclear about where in the data structure the error is being thrown.
For example, if there is an incorrect CONSTR_ID
, you get an error message saying something like:
pycardano.exception.DeserializeException: Mismatch between constructors, expect: 0, got: 1 instead.
This doesn't tell me where the constructor error is occurring. Hopefully I don't have too many 1's in my data structure.
Describe the solution you'd like
Ideally when either serializing or deserializing, errors would have some form of data structure "stack trace" for lack of a better word. An example of how this has been handled well is in pydantic.
One potential (heavy lift) implementation of this would be to rewrite the underlying PlutusData classes to use pydantic. Maybe a less heavy lift would be to use the pydantic dataclasses, and honestly, it might be as simple as using pydantic dataclasses for the decorators rather than the vanilla base dataclasses.