1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-11-29 05:46:50 +02:00

Auto prepend caller when wrapping errors

This commit is contained in:
Frederik Ring
2024-02-16 15:35:42 +01:00
parent 83fa0aae48
commit 52c22a1891
24 changed files with 313 additions and 222 deletions

View File

@@ -4,11 +4,11 @@
package main
import (
"errors"
"fmt"
"time"
"github.com/gofrs/flock"
"github.com/offen/docker-volume-backup/internal/errwrap"
)
// lock opens a lockfile at the given location, keeping it locked until the
@@ -31,7 +31,7 @@ func (s *script) lock(lockfile string) (func() error, error) {
for {
acquired, err := fileLock.TryLock()
if err != nil {
return noop, fmt.Errorf("lock: error trying to lock: %w", err)
return noop, errwrap.Wrap(err, "error trying to lock")
}
if acquired {
if s.encounteredLock {
@@ -54,7 +54,7 @@ func (s *script) lock(lockfile string) (func() error, error) {
case <-retry.C:
continue
case <-deadline.C:
return noop, errors.New("lock: timed out waiting for lockfile to become available")
return noop, errwrap.Wrap(nil, "timed out waiting for lockfile to become available")
}
}
}