Skip to content

6. Error Handling and Type Reference

6.1 ErrCode Enum

All error types share a unified ErrCode classification code:

Error CodeValueMeaning
ErrTimeout"TIMEOUT"Operation timed out
ErrNotFound"NOT_FOUND"Resource does not exist (process, context, FD, device)
ErrPermission"PERMISSION"Permission denied (e.g., writing to read-only /proc)
ErrInternal"INTERNAL"Internal error (state anomaly, serialization failure, etc.)
ErrDriver"DRIVER"Device driver error (LLM call failure, file read/write failure, etc.)
ErrInvalid"INVALID"Invalid parameter (e.g., invalid signal value)

6.2 SyscallError

Kernel-layer error, returned by all syscalls on failure.

go
type SyscallError struct {
    Syscall string        // Name of the failing syscall
    PID     types.PID     // PID of the process that invoked the syscall
    Device  string        // Related VFS path
    Err     error         // Underlying error
    Code    types.ErrCode // Categorized error code
}

Formatted Output: [TIMEOUT] PID 1 Spawn: /dev/llm/claude (context deadline exceeded)

Unwrap() Support: Implements the errors.Unwrap interface, supporting errors.Is and errors.As chained error checking.

6.3 VFSError

VFS-layer error, returned by VFS operations on failure.

go
type VFSError struct {
    Op     string        // Operation name ("Open", "Read", "Write", "Close", "Stat")
    PID    types.PID     // Process PID
    Device string        // VFS path
    Err    error         // Underlying error
    Code   types.ErrCode // Categorized error code
}

Formatted Output: [NOT_FOUND] PID 1 Open: /dev/unknown (device not found: /dev/unknown)

Unwrap() Support: Yes

6.4 DriverError

Driver-layer error, used internally by device drivers to avoid circular dependency from drivers/ to kernel/.

go
type DriverError struct {
    Op     string        // Operation name
    Device string        // Device path
    Err    error         // Underlying error
    Code   types.ErrCode // Categorized error code
}

Formatted Output: [DRIVER] Write: /dev/llm/claude (exec: command not found)

Unwrap() Support: Yes

Error Code Propagation: The VFS layer extracts the Code from DriverError via errors.As and propagates it to VFSError.

6.5 ContextError

Context-layer error.

go
type ContextError struct {
    Op   string        // Operation name ("CtxAlloc", "CtxRead", "CtxWrite", "CtxFree")
    CID  types.CtxID   // Context ID
    Err  error         // Underlying error
    Code types.ErrCode // Categorized error code
}

Formatted Output: [NOT_FOUND] CtxID 1 CtxFree: context not found

Unwrap() Support: Yes

6.6 Basic Types

TypeGo DefinitionDescription
PIDuint64Process ID (increments from 1, never recycled)
FDintFile descriptor (increments from 3)
CtxIDuint64Context ID (increments from 1)
ErrCodestringError classification code
SignalintProcess signal
ProcessStateintProcess state
UUIDuuid.UUIDUUID v7 — globally unique process identifier across daemon restarts
TraceIDstringDistributed trace identifier
SpanIDstringDistributed trace span identifier
PGIDuint64Process group identifier
TIDuint64Thread identifier
CoIDuint64Coroutine identifier

Released under the MIT License.