joule_profiler_core/profiler/
error.rs1use crate::orchestrator::error::OrchestratorError;
2use crate::source::error::MetricSourceError;
3use thiserror::Error;
4
5#[derive(Debug, Error)]
10pub enum JouleProfilerError {
11 #[error("Failed to execute command: {0}")]
13 CommandExecutionFailed(String),
14
15 #[error("Command not found: {0}")]
17 CommandNotFound(String),
18
19 #[error("The provided command is empty.")]
20 EmptyCommand,
21
22 #[error("Failed to create output file: {0}")]
24 OutputFileCreationFailed(String),
25
26 #[error("Invalid regex pattern: {0}")]
28 InvalidPattern(#[from] regex::Error),
29
30 #[error("Stdout capture failed")]
32 StdOutCaptureFail,
33
34 #[error(
36 "Cannot retrieve SUDO_USER environment variable, please retry without root privileges or use \"--use-root\" CLI argument."
37 )]
38 CannotRetrieveSudoUser,
39
40 #[error("Unable to parse {0} environment variable.")]
42 CannotParseEnvVariable(String),
43
44 #[error("Unable to retrieve current user id by it's name.")]
46 CannotRetrieveCurrentUserId,
47
48 #[error("Invalid metric unit: {0}")]
50 InvalidUnit(String),
51
52 #[error("I/O error")]
54 IoError(
55 #[from]
56 #[source]
57 std::io::Error,
58 ),
59
60 #[error("No metric sources configured.")]
62 NoSourceConfigured,
63
64 #[error("Process control failed: {0}")]
66 ProcessControlFailed(String),
67
68 #[error("Failed to spawn stdout reader thread: {0}")]
70 ReaderThreadSpawnFailed(String),
71
72 #[error("Stdout reader thread panicked")]
74 ReaderThreadPanicked,
75
76 #[error("Metric source error.")]
78 MetricSourceError(#[from] MetricSourceError),
79
80 #[error("Orchestrator error.")]
82 OrchestratorError(#[from] OrchestratorError),
83}