From da2377ecb09c19a6b9ff4b666ef00533203a3ebb Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Sun, 7 Apr 2024 11:25:16 +0200 Subject: [PATCH] Recv: Return error on stream error. --- xmpp.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xmpp.go b/xmpp.go index 0487e73..ac84e11 100644 --- a/xmpp.go +++ b/xmpp.go @@ -962,6 +962,14 @@ func (c *Client) Recv() (stanza interface{}, err error) { return Chat{}, err } switch v := val.(type) { + case *streamError: + errorMessage := v.Text.Text + if errorMessage == "" { + // v.Any is type of sub-element in failure, + // which gives a description of what failed if there was no text element + errorMessage = v.Any.Space + } + return Chat{}, errors.New("stream error: " + errorMessage) case *clientMessage: if v.Event.XMLNS == XMPPNS_PUBSUB_EVENT { // Handle Pubsub notifications