# `Linx.Process.Error`
[🔗](https://github.com/oshlabs/linx/blob/v0.2.0/lib/linx/process/error.ex#L1)

A pre-exec or transport-level failure from a `Linx.Process` session.

Stored as the session's terminal result and returned by
`Linx.Process.wait/1` (and surfaced via `Linx.Process.info/1`) as
`{:error, %Linx.Process.Error{}}`.

The *same* failure is also delivered to the session owner as the
positional event `{:linx_process, :error, errno, stage}` — where
`errno` is a raw integer. That event stays positional to match its
sibling lifecycle events (`{:linx_process, :exited, code}` etc.); this
struct is the richer, `Exception`-implementing form on the synchronous
return path, consistent with the other `%Linx.X.Error{}` types.

## Fields

  * `:stage` — the clone→exec stage that failed (`:execve`, `:clone`,
    `:seccomp_install`, …) — the Process analogue of the `:operation`
    field other error structs carry. See the stage table in
    `Linx.Process`.
  * `:errno` — the POSIX errno as an atom (`:enoent`, `:einval`, …),
    or `:unknown` for an errno Linx hasn't catalogued.
  * `:code` — the raw integer. The kernel errno for ordinary failures;
    for `stage: :agent_died` it is the agent's **process exit code**,
    not an errno (and `:errno` is `:unknown`), mirroring the documented
    `:agent_died` convention.

Implements `Exception`, so it can be `raise`d or rendered with
`Exception.message/1`.

# `t`

```elixir
@type t() :: %Linx.Process.Error{
  __exception__: true,
  code: integer() | nil,
  errno: atom(),
  stage: atom()
}
```

# `from_agent`

```elixir
@spec from_agent(integer(), atom()) :: t()
```

Builds an error from the agent's integer `code` and the `stage` atom.

For ordinary stages `code` is a kernel errno and `errno` is its POSIX
name (or `:unknown`). For `:agent_died`, `code` is the agent's exit
status — not an errno — so `errno` is `:unknown`.

---

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