diff --git a/jid/src/lib.rs b/jid/src/lib.rs index 52b7173..09b0a7f 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -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,