forked from signalfx/golib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compatibility.go
52 lines (41 loc) · 951 Bytes
/
compatibility.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package errors
type causableError interface {
Cause() error
}
type hasUnderline interface {
Underlying() error
}
// hasInner is used by dropboxgo
type hasInner interface {
GetInner() error
}
type hasMessage interface {
Message() string
}
var _ causableError = &ErrorChain{}
var _ hasUnderline = &ErrorChain{}
var _ hasMessage = &ErrorChain{}
// Cause lets me simulate errgo
func (e *ErrorChain) Cause() error {
return e.Tail()
}
// Message lets me simulate errgo
func (e *ErrorChain) Message() string {
return e.Head().Error()
}
// GetMessage is used by dropbox
func (e *ErrorChain) GetMessage() string {
return e.Head().Error()
}
// GetInner is used by dropbox
func (e *ErrorChain) GetInner() error {
return e.Head()
}
// Underlying lets me simulate errgo/facebook
func (e *ErrorChain) Underlying() error {
return e.Next()
}
// Cause of the original error at the end of the chain
func Cause(err error) error {
return Tail(err)
}