Open Adzz opened 2 years ago
A small improvement in this area https://github.com/Adzz/data_schema/pull/28
This applies to casting fns that are atoms and casting fns that are MFA tuples
Improved in https://github.com/Adzz/data_schema/pull/40
We could keep evolving the error message that is returned, eg calling the trace we give a schema-trace
suggestion it could be something like:
CSchema: field(:c)
BSchema: has_one(:b)
ASchema: has_one(:a)
When a cast function raises unexpectedly it can be tricky to see what field actually caused it. This can be helped by unit testing the cast fns (so you are sure they handle the cases you expect) and then possibly IO.inspecting the value as it comes in. But it would be nicer to be able to see which field caused the error just straight off the bat.
The obvious thing to do would be to wrap the cast__fns in a try catch but I don't like that at all...