From 3935d68d7e15ae3ca1b76b40c83d7dd43b09d97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 17 Sep 2022 16:23:53 +0200 Subject: [PATCH] error/MismatchJids: take both jids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So it's possible to see directly which jids are conflicting Signed-off-by: Maxime “pep” Buquet --- src/error.rs | 4 ++-- src/room.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/error.rs b/src/error.rs index f8ebe6e..8923f4d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -21,7 +21,7 @@ use xmpp_parsers::{FullJid, Jid}; #[derive(Debug)] pub enum Error { - MismatchJids(Jid), + MismatchJids(Jid, Jid), NickAlreadyAssigned(String), NonexistantSession(FullJid), XMPPError(TokioXMPPError), @@ -32,7 +32,7 @@ impl StdError for Error {} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Error::MismatchJids(err) => write!(f, "Mismatch Jids: {}", err), + Error::MismatchJids(jid1, jid2) => write!(f, "Mismatch Jids: {}, {}", jid1, jid2), Error::NickAlreadyAssigned(err) => write!(f, "Nickname already assigned: {}", err), Error::NonexistantSession(err) => write!(f, "Session doesn't exist: {}", err), Error::XMPPError(err) => write!(f, "XMPP error: {}", err), diff --git a/src/room.rs b/src/room.rs index 9ad77cb..9b673cb 100644 --- a/src/room.rs +++ b/src/room.rs @@ -221,7 +221,7 @@ impl Occupant { pub fn add_session(&mut self, real: FullJid) -> Result<(), Error> { if BareJid::from(real.clone()) != self.real { - return Err(Error::MismatchJids(Jid::from(real.clone()))); + return Err(Error::MismatchJids(Jid::from(self.real.clone()), Jid::from(real.clone()))); } Ok(()) @@ -229,7 +229,7 @@ impl Occupant { pub fn remove_session(&mut self, real: FullJid) -> Result<(), Error> { if BareJid::from(real.clone()) != self.real { - return Err(Error::MismatchJids(Jid::from(real.clone()))); + return Err(Error::MismatchJids(Jid::from(self.real.clone()), Jid::from(real.clone()))); } let len = self.sessions.len();