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
| Function | Description |
|---|
new | Creates a structured error value. |
raise | Raises a structured error. |
wrap | Adds a structured error around a cause. |
check | Returns a truthy value or raises a supplied error. |
pcall | Calls a function and returns normalized failures. |
is | Tests an error value against a code or code namespace. |
code_tree | Returns the checked tree for a native code namespace root. |
Defining codes
| Function | Description |
|---|
namespace | Builds checked symbols for author-defined error codes. |
Types
| Type | Description |
|---|
Error | A structured Lua error with code, message, and optional context. |
Code constants
| Constants | Description |
|---|
mux.error.codes | Checked native error-code symbols and their namespace nodes. |