pub enum Error {
Json(Error),
Io(Error),
Protocol(String),
ConnectionClosed,
Deserialization(ParseError),
ProcessFailed(i32, String),
JsonRpc {
code: i64,
message: String,
data: Option<Value>,
},
ServerClosed,
BinaryNotFound {
name: String,
},
Unknown(String),
}Expand description
All possible errors from codex-codes operations.
Variants§
Json(Error)
JSON serialization or deserialization failed.
Returned when request parameters can’t be serialized or response payloads don’t match expected types.
Io(Error)
An I/O error occurred communicating with the app-server process.
Common causes: process not found, pipe broken, permission denied.
Protocol(String)
A protocol-level error (e.g., missing stdin/stdout pipes).
ConnectionClosed
The app-server connection was closed unexpectedly.
Deserialization(ParseError)
A message from the server could not be deserialized.
Carries a ParseError with the offending method (when known),
raw frame, and the underlying serde diagnostic. If you encounter this,
please report it with the raw_line — it likely indicates a protocol
change.
ProcessFailed(i32, String)
The app-server process exited with a non-zero status.
JsonRpc
The server returned a JSON-RPC error response.
Contains the error code and message from the server, plus the
optional structured data payload verbatim. Some errors carry a typed
payload there; decode the known ones with helpers such as
Error::model_provider_error. See the Codex CLI docs for error code
meanings.
ServerClosed
The server closed the connection (EOF on stdout).
Returned by request() if the server exits mid-conversation.
BinaryNotFound
The CLI binary could not be found on PATH.
Unknown(String)
An unclassified error.
Implementations§
Source§impl Error
impl Error
Sourcepub fn jsonrpc_data(&self) -> Option<&Value>
pub fn jsonrpc_data(&self) -> Option<&Value>
The structured data of a Error::JsonRpc error, if the server sent
one. None for every other variant.
Sourcepub fn model_provider_error(&self) -> Option<ModelProviderError>
pub fn model_provider_error(&self) -> Option<ModelProviderError>
Decode a Error::JsonRpc error’s data as a
ModelProviderError.
The app-server attaches one when a thread’s stored model provider
can’t be used, e.g. thread/resume of a thread created under a
provider this machine doesn’t configure or policy forbids. None
when there is no data or it has a different shape; callers should
then fall back to code/message.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()