Enum cradle::error::Error[][src]

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

executable: OsStringsource: 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 of CommandIoError

message: Stringsource: 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 of NonZeroExitCode

full_command: Stringexit_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 of InvalidUtf8ToStdout

full_command: Stringsource: FromUtf8Error
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 of InvalidUtf8ToStderr

full_command: Stringsource: FromUtf8Error
Internal

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

Fields of Internal

message: Stringfull_command: Stringconfig: Config

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The lower-level source of this error, if any. Read more

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.