As a system that deals with validation, error design is an essential part of Thema's UX. We need a clear, consistent model for the errors that Thema will produce, including clear and easily introspected Go error types.
Each major thema operation (validation, translation) needs its own error model. Lineage binding also needs an error model - probably more urgently than either validate or translate, as the lineage binding error model is basically the "lineage typechecker" that enforces all invariants.
Properties for thema's error models should include:
- A well-defined tree of error types, identifiable via
errors.Is
- Line-level information about errors, with graceful fallback when no line-level information is available
- A clear aggregation mechanism for situations where multiple errors may occur (e.g. validation fails on multiple fields)
- Network portability, so that e.g. a standalone thema http server reliably produces the same information as would have arisen from something in-process
I got started on the mechanics of this in #82 by pulling in github.com/cockroachdb/errors, but ended up deferring it in the interest of actually the overall PR done.
This supersedes #44, as the scope of that issue was really just focused on validate errors - only one of the models we need. Still relevant is the discussion about noisy errors in disjunctions, though.
As a system that deals with validation, error design is an essential part of Thema's UX. We need a clear, consistent model for the errors that Thema will produce, including clear and easily introspected Go error types.
Each major thema operation (validation, translation) needs its own error model. Lineage binding also needs an error model - probably more urgently than either validate or translate, as the lineage binding error model is basically the "lineage typechecker" that enforces all invariants.
Properties for thema's error models should include:
errors.IsI got started on the mechanics of this in #82 by pulling in github.com/cockroachdb/errors, but ended up deferring it in the interest of actually the overall PR done.
This supersedes #44, as the scope of that issue was really just focused on validate errors - only one of the models we need. Still relevant is the discussion about noisy errors in disjunctions, though.