-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patherrors.go
42 lines (35 loc) · 885 Bytes
/
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
package etcd
import "fmt"
// NotExist is returned when a key lookup fails when calling Load or Metadata
type NotExist struct {
Key string
}
func (e NotExist) Error() string {
return fmt.Sprintf("key %s does not exist", e.Key)
}
// IsNotExistError checks to see if error is of type NotExist
func IsNotExistError(e error) bool {
switch e.(type) {
case NotExist:
return true
default:
return false
}
}
// FailedChecksum error is returned when the data retured by Load does not match the
// SHA1 checksum stored in its metadata node
type FailedChecksum struct {
Key string
}
func (e FailedChecksum) Error() string {
return fmt.Sprintf("key %s does not exist", e.Key)
}
// IsFailedChecksumError checks to see if error is of type FailedChecksum
func IsFailedChecksumError(e error) bool {
switch e.(type) {
case FailedChecksum:
return true
default:
return false
}
}