1
0
Fork 0

Add Iq.Error and define xml tags for Error type.

This commit is contained in:
Matt Goodall 2012-07-13 11:22:51 +01:00
parent 466ab47e09
commit ba349b1058
1 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,9 @@
package xmpp package xmpp
import "encoding/xml" import (
"encoding/xml"
"fmt"
)
// XMPP <iq/> stanza. // XMPP <iq/> stanza.
type Iq struct { type Iq struct {
@ -10,6 +13,7 @@ type Iq struct {
To string `xml:"to,attr,omitempty"` To string `xml:"to,attr,omitempty"`
From string `xml:"from,attr,omitempty"` From string `xml:"from,attr,omitempty"`
Payload string `xml:",innerxml"` Payload string `xml:",innerxml"`
Error *Error `xml:"error"`
} }
// Encode the value to an XML string and set as the payload. See xml.Marshal // 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"` From string `xml:"from,attr,omitempty"`
} }
// XMPP <error/> stanza. // XMPP <error/>. May occur as a top-level stanza or embedded in another
// stanza, e.g. an <iq type="error"/>.
type Error struct { type Error struct {
XMLName xml.Name `xml:"error"` 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)
} }