hitt_parser/error/
mod.rs

1#[derive(Debug)]
2pub enum RequestParseError {
3    InvalidHeaderName(String),
4    InvalidHeaderValue(String),
5    InvalidHttpMethod(String),
6    InvalidUri(String),
7    MissingMethod,
8    MissingUri,
9    VariableNotFound(String),
10}
11
12impl core::error::Error for RequestParseError {}
13
14impl core::fmt::Display for RequestParseError {
15    #[inline]
16    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
17        match self {
18            Self::InvalidHeaderName(name) => write!(f, "invalid header name '{name}'"),
19            Self::InvalidHeaderValue(value) => write!(f, "invalid header value '{value}'"),
20            Self::InvalidHttpMethod(method) => write!(f, "invalid HTTP method '{method}'"),
21            Self::InvalidUri(uri) => write!(f, "invalid uri '{uri}'"),
22            Self::MissingMethod => write!(f, "missing HTTP method"),
23            Self::MissingUri => write!(f, "missing uri"),
24            Self::VariableNotFound(value) => write!(f, "variable '{value}' was used, but not set"),
25        }
26    }
27}