IoErrorKind
public enum IoErrorKindCategorical 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
case AlreadyExistsEEXIST — the path already exists (e.g. O_CREAT | O_EXCL).
case BadFileDescriptor
case BadFileDescriptorEBADF — file descriptor is invalid or closed.
case BrokenPipe
case BrokenPipeEPIPE — write to a pipe with no reader.
case Interrupted
case InterruptedEINTR — operation interrupted by a signal.
case InvalidInput
case InvalidInputEINVAL — invalid argument to a libc call.
case IoFailure
case IoFailureEIO — generic kernel-reported I/O failure.
case IsADirectory
case IsADirectoryEISDIR — operation expected a file but got a directory.
case NoSpaceLeft
case NoSpaceLeftENOSPC — no space left on device.
case NotADirectory
case NotADirectoryENOTDIR — a path component is not a directory.
case NotFound
case NotFoundENOENT — the path does not exist.
case NotPermitted
case NotPermittedEPERM — operation not permitted.
case Other(Int32)
case Other(Int32)Any other POSIX errno — keeps the original code so callers can still dispatch on the raw value.
case OutOfMemory
case OutOfMemoryENOMEM — kernel allocation failed.
case PermissionDenied
case PermissionDeniedEACCES — caller lacks permission for the operation.
case WouldBlock
case WouldBlockEAGAIN — non-blocking call would have blocked.
Methods
public func description() -> String
public func description() -> StringShort human-readable phrase, locale-independent.
public func errno() -> Int32
public func errno() -> Int32The POSIX errno corresponding to this kind. Lossless round-trip
for all named variants and .Other.
public static func fromErrno(Int32) -> IoErrorKind
public static func fromErrno(Int32) -> IoErrorKindClassifies a POSIX errno. Unknown codes fall through to .Other(c).
Defined in lang/std/io/error.ks