data_schema icon indicating copy to clipboard operation
data_schema copied to clipboard

Feature: Better error messages

Open Adzz opened this issue 3 years ago • 3 comments

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 avatar Jun 17 '22 17:06 Adzz

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

Adzz avatar Jul 12 '22 11:07 Adzz

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

Adzz avatar Sep 16 '22 09:09 Adzz

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)

Adzz avatar Sep 28 '22 15:09 Adzz