-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy patherrors.go
More file actions
51 lines (43 loc) · 1.13 KB
/
errors.go
File metadata and controls
51 lines (43 loc) · 1.13 KB
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
package pool
import (
"fmt"
"strings"
)
// NoHostNodesError is returned when the pool does not have any hosts available.
type NoHostNodesError struct {
NumTried int
}
func (err NoHostNodesError) Error() string {
if err.NumTried == 0 {
return "no host nodes available"
}
return fmt.Sprintf("no available host nodes found after trying %d nodes", err.NumTried)
}
// VerifyFailedError is returned when a signature fails to verify. It embeds
// the underlying Cause.
type VerifyFailedError struct {
Cause error
Method string
}
func (err VerifyFailedError) Error() string {
return fmt.Sprintf("method %q failed to verify signature: %s", err.Method, err.Cause)
}
// RemoteHostErrors is used when a subset of RPC calls to hosts fail.
type RemoteHostErrors struct {
Method string
Errors []error
}
func (err RemoteHostErrors) Error() string {
if len(err.Errors) == 0 {
return "no remote host errors"
}
var s strings.Builder
fmt.Fprintf(&s, "failed to call %q on %d hosts: ", err.Method, len(err.Errors))
for i, e := range err.Errors {
s.WriteString(e.Error())
if i != len(err.Errors)-1 {
s.WriteString("; ")
}
}
return s.String()
}