> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/relay/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/relay/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/relay/_mcp/server.

# Module error

> Error handling for the FFI layer.

Generated from `cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-ffi`.

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\_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.