Linx.Tty.Error exception (Linx v0.1.0)

Copy Markdown View Source

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 raised 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.

Summary

Functions

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).

Types

t()

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

Functions

from_nif(stage, errno)

@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).