-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.go
78 lines (61 loc) · 1.66 KB
/
errors.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package swirl
import "fmt"
//type FilterNotPassedErr struct {
// Reason error
// Client Client
// Event Event
//}
//
//func (e FilterNotPassedErr) Error() string {
// return fmt.Sprintf("client (%s) failed to pass a filter: %s", e.Client.ID(), e.Reason)
//}
type ConnectionNotEstablishedErr struct {
Reason error
ConnectOptions ConnectOptions
}
type DecodingError struct {
Reason error
Client Client
Payload []byte
}
type EncodingError struct {
Reason error
EventOptions EventOptions
}
type HandlerInitializationError struct {
Reason error
EventName string
Handler interface{}
}
type HandlerNotFoundError struct {
Event string
}
type HandlerCallError struct {
Reason error
}
type FailedMessageRecoveryError struct {
Topics []string
Client Client
TimeStamp int64
}
func (f FailedMessageRecoveryError) Error() string {
return fmt.Sprintf("failed to recover data for %s (%d)", f.Client.ID(), f.TimeStamp)
}
func (e ConnectionNotEstablishedErr) Error() string {
return fmt.Sprintf("failed to establish connection: %s", e.Reason)
}
func (e DecodingError) Error() string {
return fmt.Sprintf("invalid message received from client (%s): %s", e.Client.ID(), e.Reason)
}
func (e EncodingError) Error() string {
return fmt.Sprintf("failed to encode a message: %s", e.Reason)
}
func (e HandlerNotFoundError) Error() string {
return fmt.Sprintf("failed to find a handler for event \"%s\"", e.Event)
}
func (e HandlerCallError) Error() string {
return fmt.Sprintf("failed to call a handler: %s", e.Reason)
}
func (h HandlerInitializationError) Error() string {
return fmt.Sprintf("failed to initialize a handler for event \"%s\": %s", h.EventName, h.Reason)
}