Skip to main content

Error

Enum Error 

Source
pub enum Error {
Show 15 variants NotFound, 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, }, Json { message: String, source: Error, }, VersionMismatch { found: CliVersion, minimum: CliVersion, }, DangerousNotAllowed { env_var: &'static str, }, BudgetExceeded { total_usd: f64, max_usd: f64, }, DuplexClosed, DuplexTurnInFlight, DuplexControlFailed { message: String, }, History { message: String, }, Artifacts { message: String, }, Worktrees { message: String, }, Auth { kind: AuthErrorKind, command: String, exit_code: i32, message: String, },
}
Expand description

Errors returned by claude-wrapper operations.

Variants§

§

NotFound

The claude binary was not found in PATH.

§

CommandFailed

A claude command failed with a non-zero exit code.

Fields

§command: String
§exit_code: i32
§stdout: String
§stderr: String
§working_dir: Option<PathBuf>
§

Io

An I/O error occurred while spawning or communicating with the process.

Fields

§message: String
§source: Error
§working_dir: Option<PathBuf>
§

Timeout

The command timed out.

Fields

§timeout_seconds: u64
§

Json

JSON parsing failed.

Fields

§message: String
§source: Error
§

VersionMismatch

The installed CLI version does not meet the minimum requirement.

Fields

§minimum: CliVersion
§

DangerousNotAllowed

Construction of a dangerous::Client was attempted without the opt-in env-var set. The env-var name is a compile-time constant exported from crate::dangerous::ALLOW_ENV.

Fields

§env_var: &'static str
§

BudgetExceeded

A configured BudgetTracker has hit its max_usd ceiling. Raised before the next call is dispatched, so the CLI is not invoked.

Fields

§total_usd: f64
§max_usd: f64
§

DuplexClosed

A DuplexSession operation was attempted after the session task exited (child died, EOF on stdout, or the session was closed). Pending replies are resolved with this error.

§

DuplexTurnInFlight

DuplexSession::send was called while another turn is already in flight. Wait for the outstanding turn to resolve before issuing another.

§

DuplexControlFailed

A control request issued from DuplexSession::interrupt (or any other outbound control_request) was answered by the CLI with a subtype: "error" payload.

Fields

§message: String

The error message extracted from the CLI’s control_response.

§

History

A history-module operation (parsing or locating session JSONL under ~/.claude/projects/) failed in a way that doesn’t fit the I/O or JSON variants – e.g. unknown session id, missing user home directory.

Fields

§message: String

Human-readable description of what went wrong.

§

Artifacts

An artifacts-module operation (parsing or locating files under ~/.claude/agents/, ~/.claude/skills/, and friends) failed in a way that doesn’t fit the I/O variant – e.g. unknown agent/skill name, missing user home directory.

Fields

§message: String

Human-readable description of what went wrong.

§

Worktrees

A worktrees-module operation (running or parsing git worktree list --porcelain) failed in a way that doesn’t fit the I/O variant – e.g. git not on PATH, path isn’t a git repo, malformed porcelain output.

Fields

§message: String

Human-readable description of what went wrong.

§

Auth

A claude invocation failed and looked auth-shaped to the classifier. Hosts can match on this variant to trigger a re-auth flow, surface a clean message, or skip retries. kind carries the best-effort subcategory; message is the stderr (or stdout fallback) the classifier matched against.

Raised at exec time when crate::auth::classify_failure returns Some(_) for a CLI failure that would otherwise have been Error::CommandFailed. Cases the classifier missed remain CommandFailed; call Error::auth_kind for opt-in inspection of those.

Fields

§kind: AuthErrorKind

Best-effort classification.

§command: String

The full command line that failed.

§exit_code: i32

Process exit code.

§message: String

Human-readable message extracted from stderr (or stdout).

Implementations§

Source§

impl Error

Source

pub fn from_command_failure( command: String, exit_code: i32, stdout: String, stderr: String, working_dir: Option<PathBuf>, ) -> Self

Construct an Error from a CLI failure. Runs the auth-error classifier; if it matches, returns Error::Auth. Otherwise returns Error::CommandFailed unchanged.

This is the canonical entry point for raising failures from exec.rs-shaped sites – replacing direct construction of CommandFailed ensures every consumer benefits from typed auth errors automatically.

Source

pub fn auth_kind(&self) -> Option<AuthErrorKind>

Inspect whether this error is auth-shaped. Returns Some(kind) for Error::Auth (the auto-typed path) and also re-runs crate::auth::classify_failure on Error::CommandFailed for cases the constructor missed. Returns None for everything else (Io, Timeout, etc.).

Most consumers should match on Error::Auth directly – this method is the escape hatch for low-confidence classifier patterns the constructor was too conservative about.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more