LeXtract.Error.Processing.Parsing exception (lextract v0.1.2)

View Source

Error for JSON/YAML parsing failures.

Raised when text cannot be parsed in the expected format.

Examples

iex> error = LeXtract.Error.Processing.Parsing.exception(
...>   format: :json,
...>   reason: "unexpected token at position 5"
...> )
iex> String.contains?(Exception.message(error), "JSON")
true

iex> error = LeXtract.Error.Processing.Parsing.exception(
...>   format: :yaml,
...>   reason: "invalid indentation",
...>   content_sample: "key:value\n  bad"
...> )
iex> String.contains?(Exception.message(error), "YAML")
true

Summary

Functions

Formats the error message for parsing failures.

Types

t()

@type t() :: %LeXtract.Error.Processing.Parsing{
  __exception__: true,
  bread_crumbs: term(),
  class: term(),
  content_sample: String.t() | nil,
  format: :json | :yaml,
  path: term(),
  reason: String.t(),
  splode: term(),
  stacktrace: term(),
  vars: term()
}

Functions

exception(args)

@spec exception(opts :: Keyword.t()) :: %LeXtract.Error.Processing.Parsing{
  __exception__: true,
  bread_crumbs: term(),
  class: term(),
  content_sample: term(),
  format: term(),
  path: term(),
  reason: term(),
  splode: term(),
  stacktrace: term(),
  vars: term()
}

Create an Elixir.LeXtract.Error.Processing.Parsing without raising it.

Keys

  • :format
  • :reason
  • :content_sample

message(exception)

@spec message(t()) :: String.t()

Formats the error message for parsing failures.