forked from go-redsync/redsync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
46 lines (36 loc) · 1.22 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
46
package redsync
import (
"errors"
"fmt"
)
// ErrFailed is the error resulting if Redsync fails to acquire the lock after
// exhausting all retries.
var ErrFailed = errors.New("redsync: failed to acquire lock")
// ErrExtendFailed is the error resulting if Redsync fails to extend the
// lock.
var ErrExtendFailed = errors.New("redsync: failed to extend lock")
// ErrLockAlreadyExpired is the error resulting if trying to unlock the lock which already expired.
var ErrLockAlreadyExpired = errors.New("redsync: failed to unlock, lock was already expired")
// ErrTaken happens when the lock is already taken in a quorum on nodes.
type ErrTaken struct {
Nodes []int
}
func (err ErrTaken) Error() string {
return fmt.Sprintf("lock already taken, locked nodes: %v", err.Nodes)
}
// ErrNodeTaken is the error resulting if the lock is already taken in one of
// the cluster's nodes
type ErrNodeTaken struct {
Node int
}
func (err ErrNodeTaken) Error() string {
return fmt.Sprintf("node #%d: lock already taken", err.Node)
}
// A RedisError is an error communicating with one of the Redis nodes.
type RedisError struct {
Node int
Err error
}
func (err RedisError) Error() string {
return fmt.Sprintf("node #%d: %s", err.Node, err.Err)
}