1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, Error)]
8pub enum Error {
9 #[error("connection closed")]
11 Closed,
12
13 #[error("invalid url: {0}")]
15 InvalidUrl(String),
16
17 #[error("protocol error: {0}")]
19 Protocol(String),
20
21 #[error("io error: {0}")]
23 Io(String),
24
25 #[error("tls error: {0}")]
27 Tls(String),
28
29 #[error("unsupported: {0}")]
31 Unsupported(String),
32
33 #[error("frame decode error: {0}")]
34 FrameDecode(String),
35
36 #[error("stream id error: {0}")]
37 StreamId(String),
38
39 #[error("other error: {0}")]
41 Other(String),
42}
43
44impl Error {
45 pub fn other<E: std::fmt::Display>(e: E) -> Self {
47 Self::Other(e.to_string())
48 }
49}