joule_profiler_source_procfs/error.rs
1//! Error types for the procfs metric source.
2
3use thiserror::Error;
4use tokio::task::JoinError;
5
6/// Errors that can occur while reading metrics from `/proc`.
7#[derive(Error, Debug)]
8pub enum ProcfsError {
9 /// The source was used before [`crate::Procfs::init`] was called.
10 #[error("Procfs not initialized, call init first")]
11 NotInitialized,
12
13 /// An error from the `procfs` crate (e.g., process not found, parse failure).
14 #[error(transparent)]
15 Procfs(#[from] procfs::ProcError),
16
17 /// An I/O error reading from `/proc` directly (e.g., `/proc/{pid}/task/{tid}/children`).
18 #[error(transparent)]
19 Io(#[from] std::io::Error),
20
21 /// An error occured while joining the polling task.
22 #[error("Failed to join tokio task: {0}")]
23 JoinError(
24 #[from]
25 #[source]
26 JoinError,
27 ),
28
29 #[error("procfs source mutex poisoned.")]
30 MutexPoisoned,
31}