-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherr.go
More file actions
37 lines (32 loc) · 1018 Bytes
/
err.go
File metadata and controls
37 lines (32 loc) · 1018 Bytes
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
package kvs
import "fmt"
// ErrCode is an enumeration of error codes for the key-value store.
type ErrCode int
const (
ErrUnknown ErrCode = iota
ErrNotFound
ErrDuplicate
ErrInvalidNumShards
ErrInvalidShardIndex
ErrCorruptedSnapshot
ErrUnsupportedVersion
ErrInvalidTTL
ErrStoreClosed
ErrNilHashFunc
)
var errMsg = map[ErrCode]string{
ErrUnknown: "unknown error",
ErrNotFound: "item not found",
ErrDuplicate: "item already exists",
ErrInvalidNumShards: "invalid number of shards",
ErrInvalidShardIndex: "hash function returned invalid shard index",
ErrCorruptedSnapshot: "snapshot file is corrupted",
ErrUnsupportedVersion: "snapshot version not supported",
ErrInvalidTTL: "TTL duration must be non-negative",
ErrStoreClosed: "store has been closed",
ErrNilHashFunc: "hash function cannot be nil",
}
// Error returns the string representation of an error code.
func (c ErrCode) Error() string {
return fmt.Sprintf("kvs: %v", errMsg[c])
}