error/MismatchJids: take both jids

So it's possible to see directly which jids are conflicting

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2022-09-17 16:23:53 +02:00
parent 92ca50abc7
commit 3935d68d7e
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
2 changed files with 4 additions and 4 deletions

View file

@ -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),

View file

@ -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();