The matchable error type used for format, value, and handled file failures.
Match on :reason. Show Exception.message/1 to a human. The reason is part
of the public contract; the message text is not.
The struct carries as much position information as the failing operation
knows. A parse failure knows the line. A cast failure also knows the column,
field, and offending value. A failure in a header row knows the line but not a
column; :missing_header_row has no position because no row was read. Every
position field is therefore nullable, and code that reports errors must
tolerate nil.
Summary
Types
@type reason() ::
:unterminated_quote
| :unescaped_quote
| :missing_header_row
| :missing_header
| :duplicate_header
| :extra_header
| :row_length_mismatch
| :record_too_short
| :invalid_encoding
| :value_too_wide
| :cast_failed
| :required_field_missing
| :dump_failed
| :missing_value
| :unrepresentable_value
| :io_error
Why the operation failed.
Parsing:
:unterminated_quote- a quoted field was still open at the end of input.:unescaped_quote- a character followed a closing quote where only a delimiter or a line break is allowed.
Structure:
:missing_header_row- the input ended before a header row was read.:missing_header- no column in the header row matches a declared field.:duplicate_header- a column claimed by a field appears more than once.:extra_header- a column is not claimed by any field, and the dialect was read withon_extra_header: :error.:row_length_mismatch- a row holds a different number of cells than the header row, or than the schema declares when reading without headers.:record_too_short- a fixed-width record ends before a declared field does.:detailholds{expected, actual}byte counts.:invalid_encoding- a fixed-width field's bytes are not valid UTF-8, which usually means the positions are counted wrongly or the file is in another encoding.
Values:
:cast_failed- a cell could not be read as the field's type.:required_field_missing- a field declaredrequired: truehad no value.:dump_failed- a value could not be written as the field's type.:missing_value- a row being written holds no key for a field.:unrepresentable_value- writing the value would change it or make it unreadable under the field's declared read options.:value_too_wide- a value is wider than the fixed-width field that must hold it.:detailholds{width, actual}byte counts.
Environment:
:io_error- opening, writing, or closing the file failed.:operationidentifies that operation, and:detailholds the POSIX reason.
@type t() :: %Delimited.Error{ __exception__: term(), column: pos_integer() | nil, detail: term(), field: atom() | nil, header: String.t() | nil, line: pos_integer() | nil, operation: :open | :write | :close | nil, path: Path.t() | nil, reason: reason(), schema: module() | nil, value: term() }