error.rs 922 B

1234567891011121314151617181920212223242526272829303132333435
  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 that failed to bind
  9. address: String,
  10. #[source]
  11. /// Underlying I/O error
  12. source: std::io::Error,
  13. },
  14. /// Metrics collection error
  15. #[error("Failed to collect metrics: {0}")]
  16. MetricsCollection(String),
  17. /// Registry error
  18. #[error("Registry error: {source}")]
  19. Registry {
  20. #[from]
  21. /// Underlying Prometheus error
  22. source: prometheus::Error,
  23. },
  24. /// System metrics error
  25. #[cfg(feature = "system-metrics")]
  26. #[error("System metrics error: {0}")]
  27. SystemMetrics(String),
  28. }
  29. /// Result type for Prometheus operations
  30. pub type Result<T> = std::result::Result<T, PrometheusError>;