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

A failure from one of `Linx.Tty`'s terminal syscalls.

Returned as `{:error, %Linx.Tty.Error{}}` by `open_controlling_raw/0`,
`restore_and_close/2`, `window_size/1`, and `set_window_size/2` when the
underlying `open(2)` / `tcgetattr(3)` / `tcsetattr(3)` / `ioctl(2)` /
`close(2)` fails.

## Fields

  * `:operation` — the syscall stage that failed (`:open`,
    `:tcgetattr`, `:tcsetattr`, `:ioctl`, `:close`).
  * `:errno` — the POSIX errno as an atom (`:enxio`, `:enotty`, …), or
    `:unknown` for an errno Linx hasn't catalogued.
  * `:code` — the raw errno integer, or `nil` if Linx doesn't know the
    number for that atom.

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

Note: the lifecycle conditions `attach/2` reports (`:no_local_tty`,
`:no_process`, `:gl_eof`) are **not** syscall failures and stay as bare
atoms — only kernel/syscall errors take this struct.

# `t`

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

# `from_nif`

```elixir
@spec from_nif(atom(), atom() | integer()) :: t()
```

Builds an error from the NIF's `{stage, errno}` pair, where `errno` is
either a POSIX atom (the NIF mapped it) or a raw integer (it didn't).

---

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