> For clean Markdown of any page, append .md to the page URL. For a task-oriented documentation index, fetch https://docs.nvidia.com/nemo/relay/llms.txt. Use the documentation version matching the installed NeMo Relay package: latest follows the latest stable release, vX.Y.Z identifies a retained release snapshot, and dev documents development changes. Preserve the selected version when following links; do not mix examples or API contracts from different versions. Fetch the relevant section's /llms.txt before individual pages instead of loading a complete version index. # Module error > Error handling for the FFI layer. Generated from `cargo doc --no-deps -p nemo-relay-builtins -p nemo-relay-diagnostics -p nemo-relay-logging -p nemo-relay-plugin-host -p nemo-relay-codecs -p nemo-relay -p nemo-relay-runtime -p nemo-relay-model-pricing -p nemo-relay-resource-metrics -p nemo-relay-observability -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker`. Error handling for the FFI layer. This module defines the [`NemoRelayStatus`](/reference/api/rust-library-reference/nemo-relay-ffi/error/enum-nemorelaystatus) enum returned by every exported FFI function, along with thread-local storage for human-readable error messages. After any non-`Ok` return, the caller should invoke [`nemo_relay_last_error`](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-last-error) on the same thread to obtain a diagnostic string. The error message remains valid until the next FFI call on that thread clears it via [`clear_last_error`](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-clear-last-error). ## Enums * [NemoRelayStatus](/reference/api/rust-library-reference/nemo-relay-ffi/error/enum-nemorelaystatus): Status codes returned by all FFI functions. ## Functions * [clear_last_error](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-clear-last-error): Clear the thread-local last-error message. * [last_error_message](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-last-error-message): Retrieve the last error message set on this thread, if any. * [nemo_relay_last_error](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-last-error): Retrieve the last error message set on this thread, or null if no error has occurred since the last [`clear_last_error`](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-clear-last-error) call. * [nemo_relay_last_error_cause_ids](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-last-error-cause-ids): Read the opaque callback failure IDs associated with the last error. Writes the number of IDs to `out_count`. An empty list returns null. Read on the same thread as `nemo_relay_last_error`. The returned array is borrowed until the error message or cause IDs change. Do not free it. * [nemo_relay_set_last_error_cause_ids](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-set-last-error-cause-ids): Copy opaque callback failure IDs into the current last error. Call after `nemo_relay_set_last_error_message` on the same thread. Relay carries every selected ID without changing the error text. A count of zero clears the IDs. The binding owns the data behind each ID. * [nemo_relay_set_last_error_message](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-set-last-error-message): Set the thread-local last-error message from foreign code. * [set_last_error](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-set-last-error): Store an error message in thread-local storage for later retrieval. * [status_from_error](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-status-from-error): Convert an `FlowError` to an `NemoRelayStatus`, storing the error message in thread-local storage. * [status_from_plugin_error](/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-status-from-plugin-error): Convert a `PluginError` to an `NemoRelayStatus`, storing the error message in thread-local storage. ## Docs - [Enum Nemo Relay Status](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/enum-nemorelaystatus.md): Status codes returned by all FFI functions. - [Function clear_last_error](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-clear-last-error.md): Clear the thread-local last-error message. - [Function last_error_message](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-last-error-message.md): Retrieve the last error message set on this thread, if any. - [Function nemo_relay_last_error](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-last-error.md): Retrieve the last error message set on this thread, or null if no error has occurred since the last `clear_last_error` call. - [Function nemo_relay_last_error_cause_ids](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-last-error-cause-ids.md): Read the opaque callback failure IDs associated with the last error. Writes the number of IDs to `out_count`. An empty list returns null. Read on the same thread as `nemo_relay_last_error`. The returned array is borrowed until the error message or cause IDs change. Do not free it. - [Function nemo_relay_set_last_error_cause_ids](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-set-last-error-cause-ids.md): Copy opaque callback failure IDs into the current last error. Call after `nemo_relay_set_last_error_message` on the same thread. Relay carries every selected ID without changing the error text. A count of zero clears the IDs. The binding owns the data behind each ID. - [Function nemo_relay_set_last_error_message](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-nemo-relay-set-last-error-message.md): Set the thread-local last-error message from foreign code. - [Function set_last_error](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-set-last-error.md): Store an error message in thread-local storage for later retrieval. - [Function status_from_error](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-status-from-error.md): Convert an `FlowError` to an `NemoRelayStatus`, storing the error message in thread-local storage. - [Function status_from_plugin_error](https://docs.nvidia.com/nemo/relay/v1.0.0/reference/api/rust-library-reference/nemo-relay-ffi/error/fn-status-from-plugin-error.md): Convert a `PluginError` to an `NemoRelayStatus`, storing the error message in thread-local storage.