Skip to main content

ErrorKind

Enum ErrorKind 

Source
#[non_exhaustive]
pub enum ErrorKind { NotFound, Spawn, PermissionDenied, Unsupported, Timeout, Cancelled, Predicate, Exit, Signalled, Other, }
Expand description

The kind of an Error — a total, compact classification of the failure into one bucket per operational disposition, reached through Error::kind / ErrorReason::kind.

Where ErrorReason is the structured failure mode (every field of every variant), ErrorKind is the routing classification a consumer needs when it maps failures onto its own shape — a CLI folding each disposition into a distinct process exit code, a cross-language binding raising a matching exception class, a router picking a retry policy. It is total: every ErrorReason variant — present and future — maps to exactly one kind, and the mapping is an exhaustive match inside the crate (no catch-all), so a new ErrorReason variant cannot ship without a deliberate kind decision.

It is deliberately coarser than ErrorReason and is not a replacement for matching the reason when you need the details: read Error::reason for the exit code, the captured streams, the timeout duration, the PATH searched, and so on. kind() answers “which category of failure is this?”; reason() answers “what exactly happened?”.

The shape mirrors std::io::Error / std::io::ErrorKind: a rich error carrying an open-ended set of coarse kinds (hence Other and #[non_exhaustive]). A downstream match on ErrorKind must therefore carry a catch-all arm — prefer that to enumerating every kind, so a future kind routes somewhere sane instead of breaking your build.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NotFound

The program could not be located — from ErrorReason::NotFound. The twin of Error::is_not_found; the “is it installed?” bucket.

§

Spawn

The program was located but the OS refused to start it, for a reason other than a permission denial — from a non-PermissionDenied ErrorReason::Spawn (a bad working directory, a .cmd/.bat needing cmd.exe, a transient ETXTBSY/lock, …).

§

PermissionDenied

A permission denial at the spawn/IO layer — the PermissionDenied subset of ErrorReason::Spawn / ErrorReason::Io. The twin of Error::is_permission_denied; split out of Spawn / Other because an ACL/executable-bit problem is a distinct operator action (fix permissions) from a generic launch or IO failure.

§

Unsupported

An operation is unsupported by the active containment mechanism on this platform — from ErrorReason::Unsupported (e.g. any Signal but Kill on Windows Job Objects).

§

Timeout

The run exceeded its Command::timeout and was killed — from ErrorReason::Timeout. The twin of Error::is_timeout. A readiness-probe deadline (ErrorReason::NotReady) is not this — it never kills the child — and classifies as Other, matching is_timeout’s scoping.

§

Cancelled

The run was deliberately cancelled via its CancellationToken — from ErrorReason::Cancelled. The twin of Error::is_cancelled; a caller-initiated stop, never retried.

§

Predicate

A fallible control predicate returned an error — from ErrorReason::Predicate. Its own routing bucket, distinct from Other: the failure originated in the caller’s own try_* control predicate (a Supervisor twin or ScriptedRunner::try_when), so a wrapper routing failures onto its own shape (a language binding raising a matching exception, say) can tell “the callback raised” apart from a backend/IO failure without matching the reason variant. The predicate’s verbatim error is on the reason (ErrorReason::Predicate::source).

§

Exit

The process ran to completion but exited non-zero — from ErrorReason::Exit. The exit code itself is on the reason (Error::code).

§

Signalled

The process was killed by a signal (Unix, or a modelled double/cassette) — from ErrorReason::Signalled. The twin of Error::is_signalled; the signal number, when known, is on the reason (Error::signal).

§

Other

The catch-all IO/other bucket — every remaining ErrorReason variant that is not one of the categories above: CassetteMiss, Parse, NotReady, OutputTooLarge, Stdin, and a non-PermissionDenied Io. Mirrors std::io::ErrorKind::Other: a genuine but uncategorized backend/IO failure. Read Error::reason to tell them apart when it matters.

Implementations§

Source§

impl ErrorKind

Source

pub fn name(&self) -> &'static str

This kind’s stable machine identifier: a short, lowercase snake_case string ("not_found", "permission_denied", "exit", …) that is part of the crate’s compatibility surface.

Use it for machine-readable output — a CLI’s JSONL schema, a cross-language binding, a structured log field — where a consumer needs one canonical spelling per kind instead of hand-maintaining its own mapping table. It is a diagnostic name — a stable vocabulary rather than a frozen record schema — and the exact string the opt-in report-serde feature serializes an ErrorKind as. It is held stable either way: a new kind gets a new identifier, and an existing identifier is never renamed without a major release.

There is deliberately no from_name inverse: an ErrorKind is a classification the crate reports, never one supplied back to it (the same asymmetry as Outcome::name).

Trait Implementations§

Source§

impl Clone for ErrorKind

Source§

fn clone(&self) -> ErrorKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ErrorKind

Source§

impl Debug for ErrorKind

Source§

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

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

impl Eq for ErrorKind

Source§

impl PartialEq for ErrorKind

Source§

fn eq(&self, other: &ErrorKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ErrorKind

Auto Trait Implementations§

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> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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