IoError
public struct IoError { /* private fields */ }Structured I/O error: a classified kind plus the originating POSIX
errno.
Returned in the Err arm of every Result produced by Read, Write,
File, stdio, and the os.fs helpers. Pattern-match on kind for
programmatic dispatch; call description() for a short human-readable
phrase. The convenience constructors at the bottom (notFound(),
permissionDenied(), etc.) build common kinds without spelling the enum.
Examples
match File.open("missing.txt") {
.Ok(f) => use(f),
.Err(e) => match e.kind {
.NotFound => createDefault(),
.PermissionDenied => requestAccess(),
_ => log(e.description())
}
}Properties
public var kind: IoErrorKind
public var kind: IoErrorKindInitializers
public init(code: Int32)
public init(code: Int32)Builds an error from a raw POSIX errno; classifies the kind.
public init(kind: IoErrorKind)
public init(kind: IoErrorKind)Builds an error for a categorized kind.
Methods
public func description() -> String
public func description() -> StringReturns a short human-readable phrase for the error kind. Unknown
codes yield "unknown error"; for full coverage use errno()
with a platform strerror.
public func errno() -> Int32
public func errno() -> Int32The raw POSIX error code. Use for programmatic dispatch when
pattern-matching on kind is too coarse — e.g. distinguishing
between .Other codes.
public static func last() -> IoError
public static func last() -> IoErrorSnapshots the current value of the platform's errno thread-local.
Call immediately after a failed libc call — any other libc activity
in between can clobber the value.
Defined in lang/std/io/error.ks