Skip to main content

Error

Struct Error 

Source
pub struct Error { /* private fields */ }
Expand description

The crate’s error type: a pointer-sized handle to a structured ErrorReason.

Error is a thin wrapper around a boxed ErrorReason — one pointer wide (size_of::<Error>() equals a pointer) — so a Result<T, Error> on the crate’s pervasive process-launch path, and any enum that embeds this one (a caller’s own vcs_core::Error, say), stays small instead of carrying the largest variant’s captured streams inline. The shape mirrors std::io::Error / std::io::ErrorKind.

Match on the failure mode through reason:

match err.reason() {
    ErrorReason::NotFound { program, .. } => eprintln!("install `{program}`?"),
    ErrorReason::Exit { code, .. } => eprintln!("exited with {code}"),
    _ => {}
}

or reach for the read accessors (code, program, diagnostic, the is_* predicates, …), which delegate to the inner ErrorReason. Display, Debug, and source delegate too, so the manual Debug (200-byte stream previews, PATH redaction, control-/bidi-sanitizing) and the thiserror Display behave exactly as when matching the reason directly — the wrapper adds no envelope of its own.

Implementations§

Source§

impl Error

Source

pub fn reason(&self) -> &ErrorReason

The structured ErrorReason behind this error — the enum to match on for the failure mode. Error is a pointer-sized wrapper; this borrows the boxed reason without moving it.

Source

pub fn into_reason(self) -> ErrorReason

Consume the wrapper and hand back the owned ErrorReason — for when you need to move a field out of the reason (a captured stream, the owned io::Error) rather than borrow it via reason, or to match err.into_reason() { … } and bind fields by value.

Source

pub fn kind(&self) -> ErrorKind

This failure’s ErrorKind — its total classification into one coarse routing bucket. See ErrorReason::kind for the full mapping. A routing answer, not a replacement for reason when you need the details.

Source

pub fn diagnostic(&self) -> Option<&str>

The best human-facing message for a failed run — see ErrorReason::diagnostic.

Source

pub fn stdout(&self) -> Option<&str>

The captured standard output for the stream-bearing variants — see ErrorReason::stdout.

Source

pub fn stderr(&self) -> Option<&str>

The captured standard error for the stream-bearing variants — see ErrorReason::stderr.

Source

pub fn stdout_bytes(&self) -> Option<&[u8]>

The exact captured stdout bytes, when available — see ErrorReason::stdout_bytes.

Source

pub fn combined(&self) -> Option<String>

Standard output followed by standard error, joined — see ErrorReason::combined.

Source

pub fn program(&self) -> Option<&str>

The program this error is attributed to — see ErrorReason::program.

Source

pub fn is_not_found(&self) -> bool

Whether the program could not be located — see ErrorReason::is_not_found.

Source

pub fn is_permission_denied(&self) -> bool

Whether this is a spawn/IO permission denial — see ErrorReason::is_permission_denied.

Source

pub fn is_transient(&self) -> bool

Whether this is a transient spawn/IO condition a bare retry can clear — see ErrorReason::is_transient.

Source

pub fn code(&self) -> Option<i32>

The process exit code for a non-zero Exit — see ErrorReason::code.

Source

pub fn signal(&self) -> Option<i32>

The signal number for a signal-terminated run — see ErrorReason::signal.

Source

pub fn timeout_duration(&self) -> Option<Duration>

The run deadline that elapsed for a timeout — see ErrorReason::timeout_duration.

Source

pub fn output_overflow(&self) -> Option<OutputOverflow>

The overflow counters of an output-too-large failure — see ErrorReason::output_overflow.

Source

pub fn unsupported_operation(&self) -> Option<&str>

The operation description of an unsupported-operation failure — see ErrorReason::unsupported_operation.

Source

pub fn is_timeout(&self) -> bool

Whether the run was killed for exceeding its timeout — see ErrorReason::is_timeout.

Source

pub fn is_cancelled(&self) -> bool

Whether the run was deliberately cancelled — see ErrorReason::is_cancelled.

Source

pub fn is_signalled(&self) -> bool

Whether the run was killed by a signal — see ErrorReason::is_signalled.

Source§

impl Error

Source

pub fn parse(program: impl Into<String>, message: impl Into<String>) -> Error

Construct a Parse from a caller-supplied parser’s own failure message. Unlike exit/timeout/signalled/spawn/not_found/ stdin above (#[doc(hidden)] insulated constructors meant for test doubles), this one is left on the documented public surface: an external parser that inspects a tool’s output outside this crate’s own try_parse helpers has no other way to report a parse failure as an ErrorReason::Parse once the variant is #[non_exhaustive], and that path is a normal production use, not just a test-doubling convenience.

Trait Implementations§

Source§

impl Debug for Error

Debug delegates to the inner ErrorReason’s manual Debug, so {e:?} and .unwrap() panic messages keep the same bounded stream previews and PATH redaction — the wrapper prints exactly the reason, no envelope.

Source§

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

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

impl Display for Error

Source§

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

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<ErrorReason> for Error

Source§

fn from(reason: ErrorReason) -> Error

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> 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> 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