Adzz / data_schema

Declarative schemas for data transformations.
Apache License 2.0
85 stars 9 forks source link

Feature: Better error messages #24

Open Adzz opened 2 years ago

Adzz commented 2 years ago

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...

Adzz commented 2 years ago

A small improvement in this area https://github.com/Adzz/data_schema/pull/28

Adzz commented 2 years ago

This applies to casting fns that are atoms and casting fns that are MFA tuples

Adzz commented 1 year ago

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)