| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Data.Error.Tree
Synopsis
- newtype ErrorTree = ErrorTree {
- unErrorTree :: Tree Error
- singleError :: Error -> ErrorTree
- errorTree :: Error -> NonEmpty Error -> ErrorTree
- errorTreeContext :: Text -> ErrorTree -> ErrorTree
- nestedError :: Error -> ErrorTree -> ErrorTree
- nestedMultiError :: Error -> NonEmpty ErrorTree -> ErrorTree
- prettyErrorTree :: ErrorTree -> Text
- prettyErrorTrees :: NonEmpty ErrorTree -> Text
- restrictErrorTree :: (HasField "maxlength" dat Natural, HasField "maxdepth" dat Natural) => dat -> ErrorTree -> ErrorTree
Documentation
A tree of Errors, with a single root Error and 0..n nested ErrorTrees.
top error | |-- error 1 | | | -- error 1.1 | |-- error 2
Constructors
| ErrorTree | |
Fields
| |
errorTreeContext :: Text -> ErrorTree -> ErrorTree Source #
Attach more context to the root Error of the ErrorTree, via errorContext.
nestedError :: Error -> ErrorTree -> ErrorTree Source #
Nest the given Error around the ErrorTree
top level error | -- nestedError | -- error 1 | -- error 2
prettyErrorTree :: ErrorTree -> Text Source #
restrictErrorTree :: (HasField "maxlength" dat Natural, HasField "maxdepth" dat Natural) => dat -> ErrorTree -> ErrorTree Source #
Sometimes, ErrorTrees can get very large. In that case, it’s recommended to first think about whether you can e.g. chunk the validation logic.
But even so, restricting the size of the ErrorTree before printing it is often a good idea.
This will make sure the given maxlength and maxdepth are not exceeded, and insert warnings if some subtree was elided.