joule_profiler_core/source/
error.rs1use std::{fmt::Debug, time::Duration};
2use thiserror::Error;
3
4#[derive(Debug, Error)]
9pub enum MetricSourceError {
10 #[error("Error retrieving source counters")]
12 ErrorRetrievingCounters,
13
14 #[error(
16 "source initialization timed out after {0:?}. Use --init-timeout to increase the limit."
17 )]
18 InitTimeout(Duration),
19
20 #[error(transparent)]
22 SourceError(#[from] Box<dyn std::error::Error + Send + Sync>),
23}
24
25pub trait IntoMetricSourceError {
30 fn into_metric_source_error(self) -> MetricSourceError;
31}
32
33impl<T> IntoMetricSourceError for T
34where
35 T: std::error::Error + Send + Sync + 'static,
36{
37 fn into_metric_source_error(self) -> MetricSourceError {
38 MetricSourceError::SourceError(Box::new(self))
39 }
40}