From 35932268af3eb22d1fcc2e135a3a1b1a57cae5ad Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 3 Aug 2024 15:52:15 +0200 Subject: [PATCH] =?UTF-8?q?tokio-xmpp:=20Error=20out=20when=20the=20stream?= =?UTF-8?q?:features=20couldn=E2=80=99t=20be=20parsed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is nicer than sleeping forever with no debug info whatsoever. --- tokio-xmpp/src/stream_start.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tokio-xmpp/src/stream_start.rs b/tokio-xmpp/src/stream_start.rs index f8a90338..b11349fd 100644 --- a/tokio-xmpp/src/stream_start.rs +++ b/tokio-xmpp/src/stream_start.rs @@ -1,7 +1,7 @@ use futures::{sink::SinkExt, stream::StreamExt}; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::Framed; -use xmpp_parsers::{jid::Jid, ns, stream_features::StreamFeatures}; +use xmpp_parsers::{jid::Jid, ns, stream_features::StreamFeatures, Error as ParsersError}; use crate::error::{Error, ProtocolError}; use crate::xmpp_codec::{Packet, XmppCodec}; @@ -50,9 +50,9 @@ pub async fn start( loop { match stream.next().await { Some(Ok(Packet::Stanza(stanza))) => { - if let Ok(stream_features) = StreamFeatures::try_from(stanza) { - return Ok(XMPPStream::new(jid, stream, ns, stream_id, stream_features)); - } + let stream_features = StreamFeatures::try_from(stanza) + .map_err(|e| Error::Protocol(ParsersError::from(e).into()))?; + return Ok(XMPPStream::new(jid, stream, ns, stream_id, stream_features)); } Some(Ok(_)) => {} Some(Err(e)) => return Err(e.into()),