An error returned by a Linx.Cgroup operation.
Built from a failed File.read/1 / File.write/2 / File.mkdir/1 /
File.rmdir/1 call against a cgroupfs interface file. The shape:
:path— the absolute filesystem path the operation targeted.:operation— what we were trying to do, as an atom (:create,:destroy,:read,:write,:add_process).:errno— the POSIX errno as an atom (:enoent,:eacces,:ebusy, …). File already hands us atoms; we keep them as named.:code— the matching positive errno integer, ornilif we don't have a mapping for this atom. Included for symmetry withLinx.Netlink.Errorand for callers unfamiliar with POSIX mnemonics.
Pattern-match on :errno and :operation to handle specific
failures:
case Linx.Cgroup.destroy(cg) do
:ok -> :ok
{:error, %Linx.Cgroup.Error{errno: :ebusy}} ->
# cgroup still has processes -- expected for live workloads
:not_empty
endImplements Exception, so an error can be raised or rendered
with Exception.message/1.
Summary
Functions
Builds a %Linx.Cgroup.Error{} from a posix-atom errno, the
filesystem path that failed, and the operation we attempted.
Types
@type operation() :: :create | :destroy | :read | :write | :add_process | :stats
@type t() :: %Linx.Cgroup.Error{ __exception__: true, code: pos_integer() | nil, errno: atom(), operation: operation(), path: Path.t() }
Functions
Builds a %Linx.Cgroup.Error{} from a posix-atom errno, the
filesystem path that failed, and the operation we attempted.
The integer :code is looked up from a small POSIX table; an
atom we don't have a mapping for (kernel-specific errno on
exotic hosts) keeps :code at nil.