error.rs 809 B

1234567891011121314151617181920212223242526272829303132
  1. use thiserror::Error;
  2. /// Errors that can occur in the Prometheus crate
  3. #[derive(Error, Debug)]
  4. pub enum PrometheusError {
  5. /// Server binding error
  6. #[error("Failed to bind to address {address}: {source}")]
  7. ServerBind {
  8. address: String,
  9. #[source]
  10. source: std::io::Error,
  11. },
  12. /// Metrics collection error
  13. #[error("Failed to collect metrics: {0}")]
  14. MetricsCollection(String),
  15. /// Registry error
  16. #[error("Registry error: {source}")]
  17. Registry {
  18. #[from]
  19. source: prometheus::Error,
  20. },
  21. /// System metrics error
  22. #[cfg(feature = "system-metrics")]
  23. #[error("System metrics error: {0}")]
  24. SystemMetrics(String),
  25. }
  26. /// Result type for Prometheus operations
  27. pub type Result<T> = std::result::Result<T, PrometheusError>;