use std::{env, io, process::ExitStatus};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Unable to extract test files: {0}")]
BundleExtractFailed(io::Error),
#[error("Invalid path: {0}")]
InvalidPath(io::Error),
#[error(transparent)]
JsonDeserializationFailed(#[from] serde_json::error::Error),
#[error("Missing container statistics")]
MissingContainerStats,
#[error(transparent)]
ProcessSpawnFailed(io::Error),
#[error("Error occured in runc: {0}")]
InvalidCommand(io::Error),
#[error("Runc command failed: status={status}, stdout=\"{stdout}\", stderr=\"{stderr}\"")]
CommandFailed {
status: ExitStatus,
stdout: String,
stderr: String,
},
#[error("Runc IO unavailable: {0}")]
UnavailableIO(io::Error),
#[cfg(feature = "async")]
#[error("Runc command timed out: {0}")]
CommandTimeout(tokio::time::error::Elapsed),
#[error("Unable to parse runc version")]
InvalidVersion,
#[error("Unable to locate the runc")]
NotFound,
#[error("Error occurs with fs: {0}")]
FileSystemError(io::Error),
#[error("Failed to spec file: {0}")]
SpecFileCreationFailed(io::Error),
#[error(transparent)]
SpecFileCleanupFailed(io::Error),
#[error("Failed to find valid path for spec file")]
SpecFileNotFound,
#[error("Top command is missing a pid header")]
TopMissingPidHeader,
#[error("Top command returned an empty response")]
TopShortResponseError,
#[error("Unix socket connection error: {0}")]
UnixSocketConnectionFailed(io::Error),
#[error("Unable to bind to unix socket: {0}")]
UnixSocketBindFailed(io::Error),
#[error("Unix socket failed to receive pty")]
UnixSocketReceiveMessageFailed,
#[error("Unix socket unexpectedly closed")]
UnixSocketClosed,
#[error("Failed to handle environment variable: {0}")]
EnvError(env::VarError),
#[error("Sorry, this part of api is not implemented: {0}")]
Unimplemented(String),
#[error("Error occured in runc client: {0}")]
Other(Box<dyn std::error::Error + Send>),
#[error("Failed to set cmd io: {0}")]
IoSet(String),
#[error("Failed to create dir: {0}")]
CreateDir(nix::Error),
}