mux.error package

mux.error is the built-in structured-error API. It provides stable error codes, readable messages, optional details and causes, and helpers for raising, inspecting, and preserving errors across Lua call boundaries.

Use a raised error for a contract violation or a failure the current callback cannot recover from. For an expected, recoverable failure, return nil, err instead, so the caller can decide whether and how to handle the Error.

Functions

Creating and handling errors

FunctionDescription
newCreates a structured error value.
raiseRaises a structured error.
wrapAdds a structured error around a cause.
checkReturns a truthy value or raises a supplied error.
pcallCalls a function and returns normalized failures.
isTests an error value against a code or code namespace.
code_treeReturns the checked tree for a native code namespace root.

Defining codes

FunctionDescription
namespaceBuilds checked symbols for author-defined error codes.

Types

TypeDescription
ErrorA structured Lua error with code, message, and optional context.

Code constants

ConstantsDescription
mux.error.codesChecked native error-code symbols and their namespace nodes.