Localize.DateTimeParseError exception (Localize v1.4.0)

Copy Markdown View Source

Returned (or raised) when an input string cannot be interpreted as a date, a time, a datetime or a date range.

Localize.DateTime.parse/2 returns it with :attempts unset. Localize.DateTime.Parser.parse/2, which tries each shape in turn, populates :attempts with what every sub-parser reported.

Carries semantic fields only; the human-readable description is materialised by message/1 so callers can pattern-match on structure (input/locale) without parsing prose.

Fields

  • :input — the raw string that failed to parse.

  • :locale — the locale the parser tried.

  • :attempts — a keyword list of {kind, exception} recording each sub-parser that was tried and the exception it returned, in the order they were attempted. kind is one of :interval, :date, :time or :datetime. nil when a single shape was parsed.

Summary

Types

attempt()

@type attempt() :: {kind(), Exception.t()}

kind()

@type kind() :: :interval | :date | :time | :datetime

t()

@type t() :: %Localize.DateTimeParseError{
  __exception__: term(),
  attempts: [attempt()] | nil,
  input: String.t() | nil,
  locale: atom() | String.t() | nil
}