-
Notifications
You must be signed in to change notification settings - Fork 9
/
error.go
45 lines (37 loc) · 1.06 KB
/
error.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
package lightning
import "fmt"
type ErrorConnect struct {
Path string `json:"path"`
Message string `json:"message"`
}
type ErrorNetwork struct {
URL string `json:"url"`
Message string `json:"message"`
}
type ErrorCommand struct {
Message string `json:"msg"`
Code int `json:"code"`
Data interface{} `json:"data"`
}
type ErrorTimeout struct {
Seconds int `json:"seconds"`
}
type ErrorJSONDecode struct {
Message string `json:"message"`
}
type ErrorConnectionBroken struct{}
func (c ErrorConnect) Error() string {
return fmt.Sprintf("unable to dial socket %s:%s", c.Path, c.Message)
}
func (l ErrorCommand) Error() string {
return fmt.Sprintf("lightningd replied with error: %s (%d)", l.Message, l.Code)
}
func (t ErrorTimeout) Error() string {
return fmt.Sprintf("call timed out after %ds", t.Seconds)
}
func (j ErrorJSONDecode) Error() string {
return "error decoding JSON response from lightningd: " + j.Message
}
func (c ErrorConnectionBroken) Error() string {
return "got an EOF while reading response, it seems the connection is broken"
}