-
Notifications
You must be signed in to change notification settings - Fork 323
/
error.go
50 lines (39 loc) · 1.26 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
47
48
49
50
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 (e RedisError) Error() string {
return fmt.Sprintf("node #%d: %s", e.Node, e.Err)
}
func (e RedisError) Unwrap() error {
return e.Err
}