Recv: Return error on stream error.

This commit is contained in:
Martin Dosch 2024-04-07 11:25:16 +02:00
parent 44095406a2
commit da2377ecb0

View File

@ -962,6 +962,14 @@ func (c *Client) Recv() (stanza interface{}, err error) {
return Chat{}, err return Chat{}, err
} }
switch v := val.(type) { 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: case *clientMessage:
if v.Event.XMLNS == XMPPNS_PUBSUB_EVENT { if v.Event.XMLNS == XMPPNS_PUBSUB_EVENT {
// Handle Pubsub notifications // Handle Pubsub notifications