From ba349b1058744fd9c251f2160b64eaac5d539086 Mon Sep 17 00:00:00 2001 From: Matt Goodall Date: Fri, 13 Jul 2012 11:22:51 +0100 Subject: [PATCH] Add Iq.Error and define xml tags for Error type. --- src/xmpp/stanza.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/xmpp/stanza.go b/src/xmpp/stanza.go index af1ceed..adbb4f6 100644 --- a/src/xmpp/stanza.go +++ b/src/xmpp/stanza.go @@ -1,6 +1,9 @@ package xmpp -import "encoding/xml" +import ( + "encoding/xml" + "fmt" +) // XMPP stanza. type Iq struct { @@ -10,6 +13,7 @@ type Iq struct { To string `xml:"to,attr,omitempty"` From string `xml:"from,attr,omitempty"` Payload string `xml:",innerxml"` + Error *Error `xml:"error"` } // Encode the value to an XML string and set as the payload. See xml.Marshal @@ -49,7 +53,14 @@ type Presence struct { From string `xml:"from,attr,omitempty"` } -// XMPP stanza. +// XMPP . May occur as a top-level stanza or embedded in another +// stanza, e.g. an . type Error struct { XMLName xml.Name `xml:"error"` + Type string `xml:"type,attr"` + Text string `xml:"text"` +} + +func (e Error) Error() string { + return fmt.Sprintf("%s: %s", e.Type, e.Text) }