Dextrin.Error (Dextrin v0.1.0)

Copy Markdown View Source

One error struct for both the text and binary pipelines, so a caller never has to special-case which one produced it. Wraps Ichor.Error verbatim for the text side (including its caret-annotated context_lines, useful for CLI/log output); the binary side has no source text to annotate, so it only ever carries a message, a byte offset, and a stage.

Also the channel for schema-violation errors: those come back with stage: :action, the same stage Ichor.Error already uses for Ichor.Actions-level failures (a handle_rule/3/handle_token/3 callback returning {:error, _}) — so a schema violation and a syntax error are indistinguishable by shape alone, and a caller only ever needs to check {:error, %Dextrin.Error{}}.

Summary

Types

stage()

@type stage() :: Ichor.Error.stage() | :binary

t()

@type t() :: %Dextrin.Error{
  byte_offset: non_neg_integer() | nil,
  ichor_error: Ichor.Error.t() | nil,
  message: String.t(),
  stage: stage()
}

Functions

action(message)

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

binary(message, byte_offset \\ nil)

@spec binary(String.t(), non_neg_integer() | nil) :: t()

format(error)

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

from_ichor(err)

@spec from_ichor(Ichor.Error.t()) :: t()