-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy patherror.go
More file actions
38 lines (29 loc) · 701 Bytes
/
error.go
File metadata and controls
38 lines (29 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package xco
import (
"encoding/xml"
"fmt"
"github.com/pkg/errors"
)
// Error is the error sent over XMPP
type Error struct {
XMLName xml.Name
Code string `xml:"code,omitempty,attr"`
Type string `xml:"type,omitempty,attr"`
}
func (e *Error) String() string {
return fmt.Sprintf("Error{code='%s' type='%s'}", e.Code, e.Type)
}
type multiError struct {
errs []error
mainError error
}
func (m *multiError) Error() string {
return fmt.Sprintf("%s: %s", m.mainError.Error(), m.errs)
}
func (m *multiError) Errors() []error {
return m.errs
}
func (m *multiError) Cause() error {
//FIXME: should "cause" be the mainError or the group of errors?
return errors.Errorf("%s", m.errs)
}