Enum Error

Source
pub enum Error {
    NoExecutableGiven,
    FileNotFound {
        executable: OsString,
        source: Error,
    },
    CommandIoError {
        message: String,
        source: Error,
    },
    NonZeroExitCode {
        full_command: String,
        exit_status: ExitStatus,
    },
    InvalidUtf8ToStdout {
        full_command: String,
        source: FromUtf8Error,
    },
    InvalidUtf8ToStderr {
        full_command: String,
        source: FromUtf8Error,
    },
    Internal {
        message: String,
        full_command: String,
        config: Config,
    },
}
Expand description

Error type returned when an error occurs while using [run_result!] or crate::input::Input::run_result.

[run!], crate::input::Input::run, [run_output!], and crate::input::Input::run_output will turn these errors into panics.

Variants§

§

NoExecutableGiven

The Inputs to a command must produce at least one argument: the executable to run.

use cradle::prelude::*;

let result: Result<(), cradle::Error> = run_result!(());
match result {
  Err(Error::NoExecutableGiven) => {}
  _ => panic!(),
}
§

FileNotFound

A file not found error occurred while trying to spawn the child process:

use cradle::prelude::*;

let result: Result<(), Error> = run_result!("does-not-exist");
match result {
  Err(Error::FileNotFound { .. }) => {}
  _ => panic!(),
}

Note that this error doesn’t necessarily mean that the executable file could not be found. A few other circumstances in which this can occur are:

  • a binary is dynamically linked against a library, but that library cannot be found, or
  • the executable starts with a shebang, but the interpreter specified in the shebang cannot be found.

Fields

§executable: OsString
§source: Error
§

CommandIoError

An IO error during execution. A few circumstances in which this can occur are:

  • spawning the child process fails (for another reason than FileNotFound),
  • writing to stdin of the child process fails,
  • reading from stdout or stderr of the child process fails,
  • writing to the parent’s stdout or stderr fails,
  • the given executable doesn’t have the executable flag set.

Fields

§message: String
§source: Error
§

NonZeroExitCode

The child process exited with a non-zero exit code.

use cradle::prelude::*;

let result: Result<(), cradle::Error> = run_result!("false");
match result {
  Err(Error::NonZeroExitCode { .. }) => {}
  _ => panic!(),
}

This error will be suppressed when Status is used.

Fields

§full_command: String
§exit_status: ExitStatus
§

InvalidUtf8ToStdout

The child process’s stdout is being captured, (e.g. with StdoutUntrimmed), but the process wrote bytes to its stdout that are not valid utf-8.

Fields

§full_command: String
§

InvalidUtf8ToStderr

The child process’s stderr is being captured, (with Stderr), but the process wrote bytes to its stderr that are not valid utf-8.

Fields

§full_command: String
§

Internal

This error is raised when an internal invariant of cradle is broken, and likely indicates a bug.

Fields

§message: String
§full_command: String
§config: Config

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, f: &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

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe 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, 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.