1use std::fmt::Debug;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum DeserializationError {
7 #[error("could not parse value '{value}' to enum variant of '{enum_name}'")]
8 StringToEnumParseError { enum_name: String, value: String },
9 #[error("Error while deserializing")]
10 SerdeError(#[from] serde_json::Error),
11 #[error("Error decoding character stream")]
12 DecodingError(std::str::Utf8Error),
13}
14
15#[derive(Debug, Error)]
16pub enum ServerError {
17 #[error("I/O error")]
18 IoError(std::io::Error),
19
20 #[error("Unknown header: {header}")]
21 UnknownHeader { header: String },
22
23 #[error("Parse error")]
24 ParseError(#[from] DeserializationError),
25
26 #[error("Could not parse header line '{line}'")]
27 HeaderParseError { line: String },
28
29 #[error("Protocol error while reading line '{line}', reason: '{reason}'")]
30 ProtocolError { reason: String, line: String },
31
32 #[error("Serialization error")]
33 SerializationError(#[from] serde_json::Error),
34
35 #[error(
36 "Trying to construct a non-sense response (such as an ACK for a request that requires a \
37 response body"
38 )]
39 ResponseConstructError,
40
41 #[error("Output lock is poisoned")]
42 OutputLockError,
43}