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

An error returned by the kernel in response to a netlink request.

Built from an `NLMSG_ERROR` reply: `code` is the kernel's positive errno,
`errno` is its POSIX name as an atom (`:enodev`, `:einval`, …), and
`message` is the human-readable string the kernel attached via extended ack
(`NLMSGERR_ATTR_MSG`) — `nil` if the kernel did not provide one. Extended
ack is enabled per socket by `Linx.Netlink.Socket.open/2` (Linux ≥ 4.12).

Returned in the error tuple by every netlink verb, e.g.

    {:error, %Linx.Netlink.Error{errno: :enodev}} = Link.get(socket, "nope0")

## No `:operation` field

Unlike the filesystem/procfs-backed error structs (`Linx.Cgroup.Error`,
`Linx.Mount.Error`, …), this struct carries no `:operation`. A netlink
error returns straight from the verb the caller invoked, so the operation
is already known at the call site — and the kernel's extended-ack
`message` is a richer, self-describing diagnostic than a synthetic
operation tag would be. `from_errno/2` is named for what it takes — a
numeric wire errno, not a POSIX atom — which is why it differs from the
`from_posix/_` constructors elsewhere in Linx.

This module also implements `Exception` so an error can be `raise`d, or
rendered with `Exception.message/1`.

# `t`

```elixir
@type t() :: %Linx.Netlink.Error{
  __exception__: true,
  code: pos_integer(),
  errno: atom(),
  message: binary() | nil
}
```

# `from_errno`

```elixir
@spec from_errno(pos_integer(), binary() | nil) :: t()
```

Builds an error from a positive errno `code` and an optional kernel-supplied
`message` (the `NLMSGERR_ATTR_MSG` string).

---

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