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    Timeout,
9    Parse(String),
10    Http(String),
11}
12
13impl fmt::Display for Error {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        match self {
16            Self::NotConnected => f.write_str("http conn not yet ready"),
17            Self::Closed => f.write_str("connection closed"),
18            Self::Backpressure => f.write_str("egress over cap"),
19            Self::Timeout => f.write_str("request timed out"),
20            Self::Parse(msg) => write!(f, "response parse error: {msg}"),
21            Self::Http(msg) => write!(f, "http error: {msg}"),
22        }
23    }
24}
25
26impl std::error::Error for Error {}