Macaw.Data.Fault (macaw_data v0.18.0)
View SourceThe library's one fault-to-sentence formatter (spec/00 §5): an {:error, reason}'s
term as the words a person reads.
A reason is a list of faults, {path, reason} each, or one bare reason. A fault reads
path: words, its path as Macaw.Layers.Fault.format_path/2 writes it with the empty
path named by root:, and the faults of a list are joined by "; ":
iex> Macaw.Data.Fault.sentence([{[:temp], {:length, 3}}, {[:at, 1], {:type, :time}}])
"temp: must hold 3 values, as the first column does; at[1]: must be a time: a DateTime, a NaiveDateTime or a Date"
iex> Macaw.Data.Fault.sentence([{[], {:rank, 3}}], root: "source")
"source: is a tensor of rank 3; a source's tensor has rank 1 or 2"The words are the library's reason vocabulary (words/1), then the kernel's
(Macaw.Layers.Fault), so a reason reads one way whichever function answered it. A
module with words of its own gives them as words:, tried first. A reason none of them
words reads as its term, never dropped.
Summary
Functions
One fault as path: words, with sentence/2's options.
An {:error, reason}'s term as one sentence: each fault of a list as path: words,
joined by "; ", or a bare reason's words.
The words of a reason in the library's vocabulary, nil for a reason it does not word.
Types
sentence/2's options.
@type t() :: {Macaw.Layers.Fault.path(), term()}
A fault: where, and why.
Functions
One fault as path: words, with sentence/2's options.
An {:error, reason}'s term as one sentence: each fault of a list as path: words,
joined by "; ", or a bare reason's words.
Options:
root:the name of the empty path,"value"by default;words:a module's own words for a reason,nilfor one it does not word.
The words of a reason in the library's vocabulary, nil for a reason it does not word.
iex> Macaw.Data.Fault.words({:type, :keyword})
"must be a keyword list"
iex> Macaw.Data.Fault.words(:no_such_reason)
nil