implement Error for jid crate error types

This commit is contained in:
cel 🌸 2025-02-25 18:52:14 +00:00
parent 20fc4b1966
commit 3c412ea6b0
1 changed files with 12 additions and 0 deletions

View File

@ -62,11 +62,23 @@ impl sqlx::Encode<'_, Sqlite> for JID {
}
}
#[derive(Debug)]
pub enum JIDError {
NoResourcePart,
ParseError(ParseError),
}
impl Display for JIDError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
JIDError::NoResourcePart => f.write_str("resourcepart missing"),
JIDError::ParseError(parse_error) => parse_error.fmt(f),
}
}
}
impl Error for JIDError {}
#[derive(Debug)]
pub enum ParseError {
Empty,