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
The Input
s 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!(),
}
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.
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
orstderr
of the child process fails, - writing to the parent’s
stdout
orstderr
fails, - the given executable doesn’t have the executable flag set.
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: String
exit_status: ExitStatus
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: String
source: FromUtf8Error
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: String
source: FromUtf8Error
This error is raised when an internal invariant of cradle
is broken,
and likely indicates a bug.