Skip to main content

Module error

Module error 

Source
Expand description

The error struct every fallible symbol reports through, the reserved runtime codes, and the ErrorReport mapping from producer errors.

A synchronous call takes a caller-owned {prefix}_error* out_err slot; an async completion receives a heap-boxed one it releases with {prefix}_error_free. Either way the producer allocates the message (a NUL-terminated C string) and the optional payload (a value buffer), so the producer is also the one that frees them.

Structs§

FfiError
The error struct passed across the C ABI boundary ({prefix}_error in C).

Constants§

CANCELLED_ERROR_CODE
The reserved error code reporting that an async call was cancelled: its cancel token fired, or the executor dropped the future before it completed. The completion callback still fires exactly once, with this code.
FOREIGN_ERROR_CODE
The reserved error code reporting that a consumer callback-interface implementation failed.
GENERIC_ERROR_CODE
The reserved error code for an untyped producer error: the default ErrorReport::code, used by Result<T, String> and other error types that don’t map onto a declared domain code.
MARSHAL_ERROR_CODE
The reserved error code reporting a marshalling failure: an argument that could not be lifted at the boundary (a null pointer with a non-zero length, a non-UTF-8 string, an out-of-range enum discriminant, or a malformed value buffer).
PANIC_ERROR_CODE
The reserved error code reporting a producer panic.

Traits§

ErrorDomain
An error type the #[weaveffi::error] expansion generates: a module’s error domain, decodable from a code and its payload.
ErrorReport
Maps a producer error onto the ABI’s (code, message, payload) triple.

Functions§

boxed_error
Box err for an async completion callback, which hands ownership to the consumer (released with {prefix}_error_free).
error_clear⚠
The body of {prefix}_error_clear: free any message and payload and set the code to 0. A null err is a no-op.
error_free⚠
The body of {prefix}_error_free: release a heap-boxed error delivered through an async completion, including the box. A null err is a no-op.
error_set⚠
Fill the caller’s out_err slot with code and a copy of message, releasing anything it held before. A null out_err is a no-op.
error_set_c⚠
The body of {prefix}_error_set: fill out_err from a borrowed C string the consumer owns.
error_set_payload_c⚠
The body of {prefix}_error_set_payload: replace out_err’s payload with a producer-owned copy of the len bytes at ptr. A null out_err is a no-op; a null ptr (or a len of 0) clears the payload.
error_store⚠
Move value into the caller’s out_err slot, releasing anything it held before. A null out_err drops value.
panic_message
Best-effort extraction of a panic payload’s message (&str and String payloads; anything else yields a fixed placeholder).