initial commit
This commit is contained in:
21
pkg/locker/errors.go
Normal file
21
pkg/locker/errors.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package locker
|
||||
|
||||
import "fmt"
|
||||
|
||||
type LockErr struct {
|
||||
id string
|
||||
maxRetries uint32
|
||||
err error
|
||||
}
|
||||
|
||||
func NewLockError(id string, maxRetries uint32, acquireErr error) LockErr {
|
||||
if acquireErr != nil {
|
||||
return LockErr{id: id, maxRetries: maxRetries, err: acquireErr}
|
||||
}
|
||||
|
||||
return LockErr{id, maxRetries, fmt.Errorf("failed to acquire lock after %d retries", maxRetries)}
|
||||
}
|
||||
|
||||
func (l LockErr) Error() string {
|
||||
return l.err.Error()
|
||||
}
|
||||
Reference in New Issue
Block a user