Skip to content

Commit dcca3f3

Browse files
authored
Merge pull request #789 from gingersamurai/feature/describe_retry_errors
described retried errors
2 parents 04f5273 + c0c728a commit dcca3f3

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

retry/retry.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package retry
22

33
import (
44
"context"
5-
"fmt"
65

76
"github.com/ydb-platform/ydb-go-sdk/v3/internal/backoff"
87
"github.com/ydb-platform/ydb-go-sdk/v3/internal/wait"
@@ -143,15 +142,15 @@ func Retry(ctx context.Context, op retryOperation, opts ...retryOption) (err err
143142
attempts++
144143
select {
145144
case <-ctx.Done():
146-
return xerrors.WithStackTrace(ctx.Err())
145+
return xerrors.WithStackTrace(xerrors.Errorf("retry failed on attempt No.%d: %w", attempts, ctx.Err()))
147146

148147
default:
149148
err = func() (err error) {
150149
if options.panicCallback != nil {
151150
defer func() {
152151
if e := recover(); e != nil {
153152
options.panicCallback(e)
154-
err = xerrors.WithStackTrace(fmt.Errorf("panic recovered: %v", e))
153+
err = xerrors.WithStackTrace(xerrors.Errorf("panic recovered: %v", e))
155154
}
156155
}()
157156
}
@@ -163,7 +162,7 @@ func Retry(ctx context.Context, op retryOperation, opts ...retryOption) (err err
163162
}
164163

165164
if ctxErr := ctx.Err(); ctxErr != nil {
166-
return ctxErr
165+
return xerrors.WithStackTrace(xerrors.Errorf("retry failed on attempt No.%d: %w", attempts, ctx.Err()))
167166
}
168167

169168
m := Check(err)
@@ -173,12 +172,12 @@ func Retry(ctx context.Context, op retryOperation, opts ...retryOption) (err err
173172
}
174173

175174
if !m.MustRetry(options.idempotent) {
176-
return xerrors.WithStackTrace(err)
175+
return xerrors.WithStackTrace(xerrors.Errorf("retry failed on attempt No.%d: %w", attempts, err))
177176
}
178177

179178
if e := wait.Wait(ctx, options.fastBackoff, options.slowBackoff, m.BackoffType(), i); e != nil {
180179
return xerrors.WithStackTrace(
181-
xerrors.Errorf("wait exit with error '%w' (origin error '%w')", e, err),
180+
xerrors.Errorf("retry failed on attempt No.%d: wait exit with error '%w' (origin error '%w')", attempts, e, err),
182181
)
183182
}
184183

tests/integration/table_data_query_with_compression_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ func TestDataQueryWithCompression(t *testing.T) {
6868
}
6969
}
7070
}(err)
71-
require.Equal(t, "not found column 'ghi'", err.Error())
71+
require.ErrorContains(t, err, "not found column 'ghi'")
7272
}

tests/integration/table_scan_error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ func TestIssue415ScanError(t *testing.T) {
6464
}
6565
}
6666
}(err)
67-
require.Equal(t, "not found column 'ghi'", err.Error())
67+
require.ErrorContains(t, err, "not found column 'ghi'")
6868
}

tests/integration/table_scan_query_with_compression_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ func TestScanQueryWithCompression(t *testing.T) {
6868
}
6969
}
7070
}(err)
71-
require.Equal(t, "not found column 'ghi'", err.Error())
71+
require.ErrorContains(t, err, "not found column 'ghi'")
7272
}

0 commit comments

Comments
 (0)