Skip to main content

tower_balance/
error.rs

1//! Error types
2
3use std::fmt;
4
5pub(crate) type Error = Box<dyn std::error::Error + Send + Sync>;
6
7/// An error returned when the balancer's endpoint discovery stream fails.
8#[derive(Debug)]
9pub struct Discover(pub(crate) Error);
10
11impl fmt::Display for Discover {
12    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13        write!(f, "load balancer discovery error: {}", self.0)
14    }
15}
16
17impl std::error::Error for Discover {
18    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
19        Some(&*self.0)
20    }
21}