update error enum

This commit is contained in:
yggverse 2025-03-19 03:25:55 +02:00
parent ab8eb402a8
commit 3f968d87b1
2 changed files with 27 additions and 18 deletions

View file

@ -5,19 +5,27 @@ use std::{
#[derive(Debug)]
pub enum Error {
Protocol,
Code,
HeaderLen(usize),
Utf8Error(Utf8Error),
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
Self::Code => {
write!(f, "Unexpected status code")
}
Self::HeaderLen(l) => {
write!(
f,
"Header length reached protocol limit ({l} of {} bytes max)",
super::super::HEADER_LEN
)
}
Self::Utf8Error(e) => {
write!(f, "UTF-8 error: {e}")
}
Self::Protocol => {
write!(f, "Protocol error")
}
}
}
}