capybara_core/
error.rs

1use std::borrow::Cow;
2use std::io;
3use tokio::time::error::Elapsed;
4
5#[derive(thiserror::Error, Debug)]
6pub enum CapybaraError {
7    #[error("invalid HPACK index {0}")]
8    InvalidHPackIndex(u8),
9
10    #[error("invalid huffman code")]
11    InvalidHuffmanCode,
12
13    #[error("data store disconnected")]
14    Disconnect(#[from] io::Error),
15    #[error("invalid header (expected {expected:?}, found {found:?})")]
16    InvalidHeader { expected: String, found: String },
17    #[error("unknown internal error")]
18    Unknown,
19
20    #[error("invalid configuration '{0}'")]
21    InvalidConfig(Cow<'static, str>),
22
23    #[error("invalid tls configuration '{0}'")]
24    InvalidTlsConfig(Cow<'static, str>),
25
26    #[error("invalid tls sni '{0}'")]
27    InvalidTlsSni(Cow<'static, str>),
28
29    #[error("malformed tls config: {0}")]
30    MalformedTlsConfig(anyhow::Error),
31
32    #[error("invalid route")]
33    InvalidRoute,
34
35    #[error("invalid upstream pool")]
36    InvalidUpstreamPool,
37
38    #[error("malformed http packet: {0}")]
39    MalformedHttpPacket(/* reason */ Cow<'static, str>),
40
41    #[error("request header size exceed {0} bytes")]
42    ExceedMaxHttpHeaderSize(usize),
43
44    #[error("request body size exceed {0} bytes")]
45    ExceedMaxHttpBodySize(usize),
46
47    #[error("invalid connection")]
48    InvalidConnection,
49
50    #[error("invalid properties of pipeline '{0}': {1}")]
51    InvalidPipelineConfig(/* property name */ Cow<'static, str>, anyhow::Error),
52
53    #[error("invoke filter#{0} failed: {1}")]
54    FilterExecutionFailure(/* filter index */ usize, anyhow::Error),
55
56    #[error("no address resolved from '{0}'")]
57    NoAddressResolved(/* domain */ Cow<'static, str>),
58
59    #[error("cannot parse upstream from '{0}'")]
60    InvalidUpstream(Cow<'static, str>),
61
62    #[error("operation timeout")]
63    Timeout,
64
65    #[error(transparent)]
66    Other(#[from] anyhow::Error), // source and Display delegate to anyhow::Error
67}