06 Errors and status codes

Every ABI function returns an int64_t status. Output slots are cleared on entry. On failure, a non-null error output receives an independently owned Document when allocation permits. It contains an #err map with code, message when available, and diagnostic members such as position or offset. Release it after inspection. The status remains authoritative when no diagnostic can be allocated.

Status Value Meaning
STARDUST_OK 0 The ABI call succeeded; inspect any request results separately
STARDUST_INVALID_ARGUMENT 1 Invalid arguments, options or request data
STARDUST_WRONG_KIND 2 A live handle has the wrong kind
STARDUST_INVALID_INPUT 4 Notation input cannot be decoded
STARDUST_EXHAUSTED 5 Memory or an internal sequence is exhausted
STARDUST_BUSY 6 A file is locked or another poll is active
STARDUST_UNSUPPORTED 7 An operation or format is unsupported
STARDUST_CLOSED 8 The database is closing

Use valid, live handles of the declared types. Arbitrary pointers, double release, use after release and overlapping input/output slots are caller errors. The STARDUST_WRONG_KIND check does not make arbitrary native pointers safe.