#[non_exhaustive]pub enum Error {
Show 16 variants
NotFound,
Auth {
message: String,
command: String,
exit_code: i32,
working_dir: Option<PathBuf>,
},
Config {
message: String,
command: String,
exit_code: i32,
working_dir: Option<PathBuf>,
},
NotTrustedDirectory {
message: String,
command: String,
exit_code: i32,
working_dir: Option<PathBuf>,
},
SessionNotFound {
message: String,
command: String,
exit_code: i32,
working_dir: Option<PathBuf>,
},
CommandFailed {
command: String,
exit_code: i32,
stdout: String,
stderr: String,
working_dir: Option<PathBuf>,
},
Io {
message: String,
source: Error,
working_dir: Option<PathBuf>,
},
Timeout {
timeout_seconds: u64,
},
TokenBudgetExceeded {
total_tokens: u64,
max_tokens: u64,
},
InvalidRolloutBudget {
message: String,
},
ConfigParse {
path: PathBuf,
message: String,
},
DangerousNotAllowed {
variable: &'static str,
},
Cancelled {
grace_seconds: u64,
},
Json {
message: String,
source: Error,
},
VersionMismatch {
found: CliVersion,
minimum: CliVersion,
},
UntestedCliVersion {
found: CliVersion,
tested_min: CliVersion,
tested_max: CliVersion,
},
}Expand description
Errors returned by codex-wrapper operations.
This enum is #[non_exhaustive]: match arms must include a _ catch-all so
new variants can be added without a breaking change. This mirrors
claude-wrapper’s Error for cross-crate consistency.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NotFound
The codex binary was not found in PATH.
Auth
The CLI could not authenticate.
Classified from stderr by Error::from_command_failure; see
FailureKind for what that costs. Not retried: the CLI has already
retried internally by the time this surfaces, and the credentials will
not have changed.
Fields
Config
The CLI rejected the configuration before running.
An unknown key under --strict-config, or a malformed override.
Fields
NotTrustedDirectory
The working directory is not a trusted directory or git repo, and
--skip-git-repo-check was not set.
Fields
SessionNotFound
The session or thread being resumed does not exist.
Fields
CommandFailed
A codex command failed with a non-zero exit code.
Io
An I/O error occurred while spawning or communicating with the process.
Timeout
The command timed out.
TokenBudgetExceeded
A session’s token budget was reached.
Denominated in tokens rather than money because the CLI reports token
counts and no cost; see crate::budget.
Fields
InvalidRolloutBudget
A native rollout-budget configuration was invalid before launch.
ConfigParse
A file on disk could not be parsed.
Distinct from Error::Config, which is the CLI rejecting a
configuration it was given. This one never ran a command, so it
carries no exit code and is not a FailureKind.
DangerousNotAllowed
A bypass of codex’s safety controls was requested without permission.
See crate::dangerous. Never a command failure: nothing ran.
Cancelled
The run was cancelled by the caller.
The process group was asked to stop, given grace_seconds, then
killed. Distinct from Error::Timeout, which is the client’s own
deadline rather than the caller’s decision.
Json
JSON parsing failed.
VersionMismatch
The installed CLI version does not meet the minimum requirement.
UntestedCliVersion
The installed CLI is outside the wrapper’s tested-against range.
Only returned by
Codex::ensure_tested_cli_version.
The default path reports drift as a
CliVersionStatus rather than an error.
Implementations§
Source§impl Error
impl Error
Sourcepub fn from_command_failure(
command: String,
exit_code: i32,
stdout: String,
stderr: String,
working_dir: Option<PathBuf>,
) -> Self
pub fn from_command_failure( command: String, exit_code: i32, stdout: String, stderr: String, working_dir: Option<PathBuf>, ) -> Self
Build an error from a failed command, classifying it by stderr.
Every non-zero exit in this crate goes through here, so a caller can
branch on the class rather than substring-matching stderr themselves.
An unrecognized failure stays Error::CommandFailed with its output
intact, so classification never loses information.
Classification is by message, because it has to be: every failure
observed on 0.145.0 exits 1. That makes it sensitive to the CLI
rewording a message, which is the cost of doing it here instead of in
every caller. tests/contract.rs is where a reworded message should be
caught.
Sourcepub fn failure_kind(&self) -> Option<FailureKind>
pub fn failure_kind(&self) -> Option<FailureKind>
The class of this failure, or None if it is not a command failure.
Sourcepub fn exit_code(&self) -> Option<i32>
pub fn exit_code(&self) -> Option<i32>
The process exit code, for any variant that came from one.
Classification moved some failures off Error::CommandFailed, so
anything reading an exit code should read it here rather than matching
that one variant.
Sourcepub fn is_deterministic_failure(&self) -> bool
pub fn is_deterministic_failure(&self) -> bool
Whether re-running the identical command could plausibly succeed.
False for the classified failures: each is a deterministic rejection, and the CLI has already retried the auth case internally before it surfaces here.
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()