Errors v0.1.0

Source
The error numbers, and telling a raw result from an error.

EPERM

pub const EPERM: int64 = 1;

EPERM: the operation is not permitted to this caller.

Source

ENOENT

pub const ENOENT: int64 = 2;

ENOENT: no such file or directory.

Source

ESRCH

pub const ESRCH: int64 = 3;

ESRCH: no process has that identifier.

Source

EINTR

pub const EINTR: int64 = 4;

EINTR: the call was interrupted by a signal before it did anything.

Source

EIO

pub const EIO: int64 = 5;

EIO: a low-level input or output error.

Source

ENXIO

pub const ENXIO: int64 = 6;

ENXIO: no such device or address.

Source

EBADF

pub const EBADF: int64 = 9;

EBADF: the file descriptor is not open, or is not open for what was asked.

Source

ENOMEM

pub const ENOMEM: int64 = 12;

ENOMEM: not enough memory to satisfy the request.

Source

EACCES

pub const EACCES: int64 = 13;

EACCES: permission denied.

Source

EFAULT

pub const EFAULT: int64 = 14;

EFAULT: an address the call was given is outside the caller's address space.

Source

EBUSY

pub const EBUSY: int64 = 16;

EBUSY: the resource is in use by something else.

Source

EEXIST

pub const EEXIST: int64 = 17;

EEXIST: the file already exists.

Source

EXDEV

pub const EXDEV: int64 = 18;

EXDEV: the two paths are on different file systems.

Source

ENOTDIR

pub const ENOTDIR: int64 = 20;

ENOTDIR: a path component that had to be a directory is not one.

Source

EISDIR

pub const EISDIR: int64 = 21;

EISDIR: the target is a directory and the operation is not one a directory accepts.

Source

EINVAL

pub const EINVAL: int64 = 22;

EINVAL: an argument is not valid.

Source

EMFILE

pub const EMFILE: int64 = 24;

EMFILE: this process has too many descriptors open.

Source

ENOSPC

pub const ENOSPC: int64 = 28;

ENOSPC: the device has no room left.

Source

ESPIPE

pub const ESPIPE: int64 = 29;

ESPIPE: the descriptor is a pipe or socket and cannot be seeked.

Source

EROFS

pub const EROFS: int64 = 30;

EROFS: the file system is mounted read-only.

Source

EPIPE

pub const EPIPE: int64 = 32;

EPIPE: the reading end of the pipe is closed.

Source

EAGAIN

pub const EAGAIN: int64 = 35;

EAGAIN: the operation would block, and the descriptor was set not to.

Source

ELOOP

pub const ELOOP: int64 = 62;

ELOOP: too many symbolic links were followed resolving the path.

Source

ENAMETOOLONG

pub const ENAMETOOLONG: int64 = 63;

ENAMETOOLONG: the path or a component of it is too long.

Source

ENOSYS

pub const ENOSYS: int64 = 78;

ENOSYS: the system does not implement this call.

Source

EOVERFLOW

pub const EOVERFLOW: int64 = 84;

EOVERFLOW: a value is too large for the type the call reports it in.

Source

ETIMEDOUT

pub const ETIMEDOUT: int64 = 60;

ETIMEDOUT: the operation timed out.

Source

MaximumErrno

pub const MaximumErrno: int64 = 4095;

The largest error number the normalized error range holds.

Source

CurrentErrno

pub func CurrentErrno() -> int64

The calling thread's current errno value. Takes nothing and returns the value by copy. Meaningful only immediately after a call that failed: nothing on Darwin clears it on success, so a value left over from an earlier failure is still there. Cannot fail. Runs in constant time and allocates nothing.

Source

Returns: the calling thread's current errno

Normalize

pub func Normalize(result: int64) -> int64

Folds a libSystem result and the thread's errno into one value. result is read by value. A result of -1 becomes the negative of whatever errno holds; anything else is returned unchanged. That is what makes every wrapper in this package report the way the Linux and FreeBSD ones do, so a caller reads all three with IsError and Errno. A call that legitimately returns -1 would be misread, which is why nothing here wraps one. Cannot fail. Runs in constant time and allocates nothing.

Source

Parameters

NameTypeDescription
resultint64the libSystem result to fold

Returns: the result unchanged, or the negative of errno when it was -1

IsError

pub func IsError(result: int64) -> bool

Whether a normalized result is one of the reserved error values. result is read by value. True for -4095 through -1. Cannot fail. Runs in constant time and allocates nothing.

Source

Parameters

NameTypeDescription
resultint64the raw result to test

Returns: whether it is one of the reserved error values

Errno

pub func Errno(result: int64) -> int64

The error number a normalized result carries, or zero when it carries none. result is read by value; the number is returned positive, as a man page names it. Cannot fail. Runs in constant time and allocates nothing.

Source

Parameters

NameTypeDescription
resultint64the raw result to read

Returns: the error number, positive, or zero when the result carries none