IoErrorKind

public enum IoErrorKind

Categorical classification of an I/O error.

IoError carries one of these alongside its raw errno. The named variants cover the common categories applications dispatch on; everything else falls into .Other carrying the original POSIX code so no information is lost. Built from a code via IoErrorKind.fromErrno(code:), or matched directly in error-handling code:

match e.kind { .NotFound => createDefault(), .PermissionDenied => promptForElevation(), .Other(c) => log("unhandled errno: " + c.toString()) }

Cases

case AlreadyExists

EEXIST — the path already exists (e.g. O_CREAT | O_EXCL).

case BadFileDescriptor

EBADF — file descriptor is invalid or closed.

case BrokenPipe

EPIPE — write to a pipe with no reader.

case Interrupted

EINTR — operation interrupted by a signal.

case InvalidInput

EINVAL — invalid argument to a libc call.

case IoFailure

EIO — generic kernel-reported I/O failure.

case IsADirectory

EISDIR — operation expected a file but got a directory.

case NoSpaceLeft

ENOSPC — no space left on device.

case NotADirectory

ENOTDIR — a path component is not a directory.

case NotFound

ENOENT — the path does not exist.

case NotPermitted

EPERM — operation not permitted.

case Other(Int32)

Any other POSIX errno — keeps the original code so callers can still dispatch on the raw value.

case OutOfMemory

ENOMEM — kernel allocation failed.

case PermissionDenied

EACCES — caller lacks permission for the operation.

case WouldBlock

EAGAIN — non-blocking call would have blocked.

Methods

public func description() -> String

Short human-readable phrase, locale-independent.

public func errno() -> Int32

The POSIX errno corresponding to this kind. Lossless round-trip for all named variants and .Other.

public static func fromErrno(Int32) -> IoErrorKind

Classifies a POSIX errno. Unknown codes fall through to .Other(c).

Defined in lang/std/io/error.ks