22 lines
441 B
Go
22 lines
441 B
Go
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()
|
|
}
|