ExBurn.Error exception (ex_burn v0.3.0)

Copy Markdown View Source

Structured error type for ExBurn operations.

Fields

  • :op — the operation that failed (e.g., :add, :matmul, :conv)
  • :reason — a human-readable error message
  • :details — optional map with additional context (shapes, types, etc.)

Examples

raise ExBurn.Error, op: :matmul, reason: "shape mismatch",
  details: %{lhs: [3, 4], rhs: [5, 6]}

Summary

Functions

Formats an error for logging or display.

Wraps an error tuple in an ExBurn.Error.

Creates an error struct (non-raising).

Converts the error to a string representation suitable for logging.

Types

t()

@type t() :: %ExBurn.Error{
  __exception__: true,
  details: map() | nil,
  op: atom(),
  reason: String.t()
}

Functions

format_error(error)

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

Formats an error for logging or display.

Returns a string with the operation, reason, and any details.

from_tuple(arg, opts)

@spec from_tuple({:error, String.t()}, keyword()) :: t()

Wraps an error tuple in an ExBurn.Error.

Examples

iex> ExBurn.Error.from_tuple({:error, "something failed"}, op: :forward)
%ExBurn.Error{op: :forward, reason: "something failed", details: nil}

new(opts \\ [])

@spec new(keyword()) :: t()

Creates an error struct (non-raising).

Useful for returning errors in pipelines without raising.

Examples

iex> ExBurn.Error.new(op: :add, reason: %{"bad input"})
%ExBurn.Error{op: :add, reason: "bad input", details: nil}

to_log_string(error)

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

Converts the error to a string representation suitable for logging.