# `ExBurn.Error`
[🔗](https://github.com/ohhi-vn/ex_burn/blob/main/lib/ex_burn/error.ex#L1)

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]}

# `t`

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

# `format_error`

```elixir
@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`

```elixir
@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`

```elixir
@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`

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

Converts the error to a string representation suitable for logging.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
