blob: 215b7b04ad18ed6fb129056b5d3c19783b33703e [file] [log] [blame] [view]
# Errors
This describes the set of userspace-exposed errors used in Zircon. The first section provides the
canonical names and description of each error code. The second section provides the concrete values.
Within the kernel, errors are typically resulted as variables of type `status_t` and errors are
defined by macros of the form `ZX_ERR_CANONICAL_NAME` e.g. `ZX_ERR_INTERNAL`. All error cases are negative
values and success is represented by a non-negative value.
In userspace the syscall dispatch layer (libzircon) exposes the result values as variables of type
`zx_status_t` that currently use the same spelling and values as the kernel for errors, but which
will transition to using 0 for success and positive values for errors.
See [Kernel internal errors]( for a list of kernel-internal values.
## Descriptions
Each category represents a class of errors. The first error code in each category is the generic
code for that category and is used when no more specific code applies. Further error codes (if any)
within a category represent particular types of errors within the class. In general, more specific
error codes are preferred where possible.
Errors are described in terms of an operation, arguments, a subject, and identifiers. An operation
is typically a function or system call. Arguments are typically the parameters to the call. The
subject of an operation is the primary object the operation acts on, typically a handle and
typically passed as the first argument. Identifiers are typically numbers or strings intended to
unambiguously identify a resource used in the operation.
## Categories
### Success
Operation succeeded.
### General errors
These indicate that the system hit a general error while attempting the operation.
The system encountered an otherwise unspecified error while performing the operation.
The operation is not supported, implemented, or enabled.
The system was not able to allocate some resource needed for the operation.
The system was not able to allocate memory needed for the operation.
### Parameter errors
These indicate that the caller specified a parameter that does not specify a valid operation or that
is invalid for the specified operation.
An argument is invalid.
The subject of the operation is the wrong type to perform the operation.
Example: Attempting a message\_read on a thread handle.
The specified syscall number is invalid.
A specified handle value does not refer to a handle.
An argument is outside the valid range for this operation.
Note: This is used when the argument may be valid if the system changes state, unlike
INVALID\_ARGUMENT which is used when the argument will never be valid.
A caller provided buffer is too small for this operation.
### Precondition or state errors
These indicate that the operation could not succeed because the preconditions for the operation are
not satisfied or the system is unable to complete the operation in its current state.
The system is unable to perform the operation in its current state.
Note: FAILED\_PRECONDITION is a reserved alias for this error
The requested entity was not found.
The time limit for the operation elapsed before the operation completed.
An object with the specified identifier already exists.
Example: Attempting to create a file when a file already exists with that name.
The operation failed because the named entity is already owned or controlled by another entity.
The operation could succeed later if the current owner releases the entity.
A handle being waited on was closed.
The operation failed because the remote end of the subject of the operation was closed.
The subject of the operation is currently unable to perform the operation.
Note: This is used when there's no direct way for the caller to observe when the subject will be
able to perform the operation and should thus retry.
The operation cannot be performed currently but potentially could succeed if the caller waits for
a prerequisite to be satisfied, for example waiting for a handle to be readable or writable.
Example: Attempting to read from a channel that has no messages waiting but has an open
remote will return **SHOULD\_WAIT**. Attempting to read from a channel that has no messages
waiting and has a closed remote end will return **REMOTE\_CLOSED**.
### Permission errors
The caller did not have permission to perform the specified operation.
### Input/output errors
Otherwise unspecified error occurred during I/O.
The entity the I/O operation is being performed on rejected the operation.
Example: an I2C device NAK'ing a transaction or a disk controller rejecting an invalid command.
The data in the operation failed an integrity check and is possibly corrupted.
Example: CRC or Parity error.
The data in the operation is currently unavailable and may be permanently lost.
Example: A disk block is irrecoverably damaged.