forked from jshiffer/go-xmpp
XEP-0478: Further improve error message.
This commit is contained in:
parent
416bb6e7b7
commit
78d07e9eee
10
xmpp.go
10
xmpp.go
@ -1214,7 +1214,7 @@ func (c *Client) Send(chat Chat) (n int, err error) {
|
|||||||
stanza := fmt.Sprintf("<message to='%s' type='%s' id='%s' xml:lang='en'>"+subtext+"<body>%s</body>"+oobtext+thdtext+"</message>\n",
|
stanza := fmt.Sprintf("<message to='%s' type='%s' id='%s' xml:lang='en'>"+subtext+"<body>%s</body>"+oobtext+thdtext+"</message>\n",
|
||||||
xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce(), xmlEscape(chat.Text))
|
xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce(), xmlEscape(chat.Text))
|
||||||
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
||||||
return 0, fmt.Errorf("stanza size (%v bytes) exceeds limit (%v bytes)",
|
return 0, fmt.Errorf("stanza size (%v bytes) exceeds server limit (%v bytes)",
|
||||||
len(stanza), c.LimitMaxBytes)
|
len(stanza), c.LimitMaxBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,7 +1237,7 @@ func (c *Client) SendOOB(chat Chat) (n int, err error) {
|
|||||||
stanza := fmt.Sprintf("<message to='%s' type='%s' id='%s' xml:lang='en'>"+oobtext+thdtext+"</message>\n",
|
stanza := fmt.Sprintf("<message to='%s' type='%s' id='%s' xml:lang='en'>"+oobtext+thdtext+"</message>\n",
|
||||||
xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce())
|
xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce())
|
||||||
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
||||||
return 0, fmt.Errorf("stanza size (%v bytes) exceeds limit (%v bytes)",
|
return 0, fmt.Errorf("stanza size (%v bytes) exceeds server limit (%v bytes)",
|
||||||
len(stanza), c.LimitMaxBytes)
|
len(stanza), c.LimitMaxBytes)
|
||||||
}
|
}
|
||||||
return fmt.Fprint(c.stanzaWriter, stanza)
|
return fmt.Fprint(c.stanzaWriter, stanza)
|
||||||
@ -1247,7 +1247,7 @@ func (c *Client) SendOOB(chat Chat) (n int, err error) {
|
|||||||
func (c *Client) SendOrg(org string) (n int, err error) {
|
func (c *Client) SendOrg(org string) (n int, err error) {
|
||||||
stanza := fmt.Sprint(org + "\n")
|
stanza := fmt.Sprint(org + "\n")
|
||||||
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
||||||
return 0, fmt.Errorf("stanza size (%v bytes) exceeds limit (%v bytes)",
|
return 0, fmt.Errorf("stanza size (%v bytes) exceeds server limit (%v bytes)",
|
||||||
len(stanza), c.LimitMaxBytes)
|
len(stanza), c.LimitMaxBytes)
|
||||||
}
|
}
|
||||||
return fmt.Fprint(c.stanzaWriter, stanza)
|
return fmt.Fprint(c.stanzaWriter, stanza)
|
||||||
@ -1296,7 +1296,7 @@ func (c *Client) SendPresence(presence Presence) (n int, err error) {
|
|||||||
|
|
||||||
stanza := fmt.Sprintf(buf + "</presence>")
|
stanza := fmt.Sprintf(buf + "</presence>")
|
||||||
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
||||||
return 0, fmt.Errorf("stanza size (%v bytes) exceeds limit (%v bytes)",
|
return 0, fmt.Errorf("stanza size (%v bytes) exceeds server limit (%v bytes)",
|
||||||
len(stanza), c.LimitMaxBytes)
|
len(stanza), c.LimitMaxBytes)
|
||||||
}
|
}
|
||||||
return fmt.Fprint(c.stanzaWriter, stanza)
|
return fmt.Fprint(c.stanzaWriter, stanza)
|
||||||
@ -1313,7 +1313,7 @@ func (c *Client) SendHtml(chat Chat) (n int, err error) {
|
|||||||
"<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html></message>\n",
|
"<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html></message>\n",
|
||||||
xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text), chat.Text)
|
xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text), chat.Text)
|
||||||
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
|
||||||
return 0, fmt.Errorf("stanza size (%v bytes) exceeds limit (%v bytes)",
|
return 0, fmt.Errorf("stanza size (%v bytes) exceeds server limit (%v bytes)",
|
||||||
len(stanza), c.LimitMaxBytes)
|
len(stanza), c.LimitMaxBytes)
|
||||||
}
|
}
|
||||||
return fmt.Fprint(c.stanzaWriter, stanza)
|
return fmt.Fprint(c.stanzaWriter, stanza)
|
||||||
|
Loading…
Reference in New Issue
Block a user