pa-error-tree-0.1.1.0: Collect a tree of errors and pretty-print
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Error.Tree

Synopsis

Documentation

newtype ErrorTree Source #

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 

Instances

Instances details
IsString ErrorTree Source # 
Instance details

Defined in Data.Error.Tree

Show ErrorTree Source # 
Instance details

Defined in Data.Error.Tree

singleError :: Error -> ErrorTree Source #

Turn a single Error into an ErrorTree, a leaf.

errorTree :: Error -> NonEmpty Error -> ErrorTree Source #

Take a list of errors & create a new ErrorTree with the given Error as the root.

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

nestedMultiError :: Error -> NonEmpty ErrorTree -> ErrorTree Source #

Nest the given Error around the list of ErrorTrees.

top level error
|
|- nestedError1
| |
| -- error 1
| |
| -- error 2
|
|- nestedError 2

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.