retry: explicitly log failed requests

This simplifies finding the request in the log output that cause an
operation to fail.
This commit is contained in:
Michael Eischer
2024-04-29 21:07:17 +02:00
parent 8898f61717
commit a3633cad9e
3 changed files with 45 additions and 12 deletions

View File

@@ -416,7 +416,11 @@ func OpenRepository(ctx context.Context, opts GlobalOptions) (*repository.Reposi
}
report := func(msg string, err error, d time.Duration) {
Warnf("%v returned error, retrying after %v: %v\n", msg, d, err)
if d >= 0 {
Warnf("%v returned error, retrying after %v: %v\n", msg, d, err)
} else {
Warnf("%v failed: %v\n", msg, err)
}
}
success := func(msg string, retries int) {
Warnf("%v operation successful after %d retries\n", msg, retries)