use crate::orchestrator::error::OrchestratorError;
use crate::source::error::MetricSourceError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum JouleProfilerError {
#[error("Failed to execute command: {0}")]
CommandExecutionFailed(String),
#[error("Command not found: {0}")]
CommandNotFound(String),
#[error("The provided command is empty.")]
EmptyCommand,
#[error("Failed to create output file: {0}")]
OutputFileCreationFailed(String),
#[error("Invalid regex pattern: {0}")]
InvalidPattern(#[from] regex::Error),
#[error("Stdout capture failed")]
StdOutCaptureFail,
#[error(
"Cannot retrieve SUDO_USER environment variable, please retry without root privileges or use \"--use-root\" CLI argument."
)]
CannotRetrieveSudoUser,
#[error("Unable to parse {0} environment variable.")]
CannotParseEnvVariable(String),
#[error("Unable to retrieve current user id by it's name.")]
CannotRetrieveCurrentUserId,
#[error("Invalid metric unit: {0}")]
InvalidUnit(String),
#[error("I/O error")]
IoError(
#[from]
#[source]
std::io::Error,
),
#[error("No metric sources configured.")]
NoSourceConfigured,
#[error("Process control failed: {0}")]
ProcessControlFailed(String),
#[error("Failed to spawn stdout reader thread: {0}")]
ReaderThreadSpawnFailed(String),
#[error("Stdout reader thread panicked")]
ReaderThreadPanicked,
#[error("Metric source error.")]
MetricSourceError(#[from] MetricSourceError),
#[error("Orchestrator error.")]
OrchestratorError(#[from] OrchestratorError),
}