Calendrical.DateRangeParseError exception (Calendrical v0.7.0)

Copy Markdown

Returned (or raised) by Calendrical.Date.parse_range/2 when an input cannot be interpreted as a date range, or when both endpoints parsed successfully but the resulting range is invalid.

Carries semantic fields only; the human-readable description is materialised by message/1. Pattern-match on :reason to branch on failure category without parsing prose.

Fields

  • :input — the raw input that was passed in. A binary for the single-string form, a {from, to} tuple for the pair form.

  • :reason — atom describing the failure category. See reason_atoms/0 for the closed set of permitted values.

  • :locale — the locale the parser tried. Set for failures surfaced before sub-parsing (e.g. :no_separator).

  • :from, :to — the parsed endpoints. Set when the failure occurs after both endpoints parsed successfully (e.g. :inverted).

  • :cause — the wrapped inner exception when this error is a wrapper for a sub-parser failure (:from_parse_failed / :to_parse_failed). nil otherwise.

Summary

Types

reason()

@type reason() :: :no_separator | :inverted | :from_parse_failed | :to_parse_failed

t()

@type t() :: %Calendrical.DateRangeParseError{
  __exception__: term(),
  cause: Exception.t() | nil,
  from: Date.t() | nil,
  input: term(),
  locale: atom() | String.t() | nil,
  reason: reason() | nil,
  to: Date.t() | nil
}