scratch_server/errors/
http_parse_error.rs1use std::fmt;
2
3#[derive(Debug)]
4pub struct HttpParseError {
5 pub message: String,
6}
7
8impl fmt::Display for HttpParseError {
9 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10 write!(f, "{}", self.message)
11 }
12}
13
14impl std::error::Error for HttpParseError {}
15
16impl From<std::io::Error> for HttpParseError {
17 fn from(error: std::io::Error) -> Self {
18 HttpParseError {
19 message: error.to_string(),
20 }
21 }
22}
23
24impl Default for HttpParseError {
25 fn default() -> Self {
26 HttpParseError {
27 message: "An error occurred while parsing the HTTP request".to_string(),
28 }
29 }
30}