Skip to main content

sark_client/connector/
error.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum Error {
5    NotConnected,
6    Closed,
7    Backpressure,
8    CapacityOverflow,
9    WaiterCapacity,
10    Timeout,
11    Parse(String),
12    Http(String),
13}
14
15impl fmt::Display for Error {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        match self {
18            Self::NotConnected => f.write_str("http conn not yet ready"),
19            Self::Closed => f.write_str("connection closed"),
20            Self::Backpressure => f.write_str("egress over cap"),
21            Self::CapacityOverflow => f.write_str("response buffer capacity exceeded"),
22            Self::WaiterCapacity => f.write_str("waiter capacity exhausted"),
23            Self::Timeout => f.write_str("request timed out"),
24            Self::Parse(msg) => write!(f, "response parse error: {msg}"),
25            Self::Http(msg) => write!(f, "http error: {msg}"),
26        }
27    }
28}
29
30impl std::error::Error for Error {}