Macaw.Data.Error exception (macaw_data v0.12.0)
View SourceWhat every ! twin raises (spec/00 §5): its value twin's {:error, reason}, with the
reason's term kept and its words for the message.
reason is the term exactly as the twin answers it, a list of {path, reason} faults or
one bare reason, so a caller that catches nothing still reads the terms in a crash
report, and a test asserts them without parsing words:
iex> error = Macaw.Data.Error.exception(reason: [{[:temp], {:length, 3}}], what: "not a table")
iex> {error.reason, Exception.message(error)}
{[{[:temp], {:length, 3}}], "not a table: temp: must hold 3 values, as the first column does"}exception/1 takes reason: and words it with Macaw.Data.Fault.sentence/2, passing
root: and words: along. what: names what the input is not, and starts the message.
A twin whose module already words its reasons gives the message whole, as message:.