mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use std::fmt::{Display, Formatter, Result};
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
Default(super::default::Error),
|
|
FirstByte(u8),
|
|
Protocol,
|
|
SecondByte(u8),
|
|
Sensitive(super::sensitive::Error),
|
|
UndefinedFirstByte,
|
|
UndefinedSecondByte,
|
|
}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut Formatter) -> Result {
|
|
match self {
|
|
Self::Default(e) => {
|
|
write!(f, "Default parse error: {e}")
|
|
}
|
|
Self::FirstByte(b) => {
|
|
write!(f, "Unexpected first byte: {b}")
|
|
}
|
|
Self::Protocol => {
|
|
write!(f, "Protocol error")
|
|
}
|
|
Self::SecondByte(b) => {
|
|
write!(f, "Unexpected second byte: {b}")
|
|
}
|
|
Self::Sensitive(e) => {
|
|
write!(f, "Sensitive parse error: {e}")
|
|
}
|
|
Self::UndefinedFirstByte => {
|
|
write!(f, "Undefined first byte")
|
|
}
|
|
Self::UndefinedSecondByte => {
|
|
write!(f, "Undefined second byte")
|
|
}
|
|
}
|
|
}
|
|
}
|