Skip to content

Commit 2f6023f

Browse files
committed
fix errname issues
1 parent c6e45cd commit 2f6023f

File tree

11 files changed

+35
-36
lines changed

11 files changed

+35
-36
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ linters:
219219
- cyclop
220220
- depguard
221221
- dupl
222-
- errname
223222
- exhaustive
224223
- exhaustivestruct
225224
- exhaustruct

internal/conn/error_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@ func TestNodeErrorIs(t *testing.T) {
3232
require.NotErrorIs(t, nodeErr, testErr2)
3333
}
3434

35-
type testErrorType1 struct {
35+
type testType1Error struct {
3636
msg string
3737
}
3838

39-
func (t testErrorType1) Error() string {
39+
func (t testType1Error) Error() string {
4040
return "1 - " + t.msg
4141
}
4242

43-
type testErrorType2 struct {
43+
type testType2Error struct {
4444
msg string
4545
}
4646

47-
func (t testErrorType2) Error() string {
47+
func (t testType2Error) Error() string {
4848
return "2 - " + t.msg
4949
}
5050

5151
func TestNodeErrorAs(t *testing.T) {
52-
testErr := testErrorType1{msg: "test"}
52+
testErr := testType1Error{msg: "test"}
5353
nodeErr := newConnError(1, "localhost:1234", testErr)
5454

55-
target := testErrorType1{}
55+
target := testType1Error{}
5656
require.ErrorAs(t, nodeErr, &target)
5757
require.Equal(t, testErr, target)
5858

59-
target2 := testErrorType2{}
59+
target2 := testType2Error{}
6060
require.False(t, errors.As(nodeErr, &target2))
6161
}

internal/topic/topicreaderinternal/decoders.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (m *decoderMap) Decode(codec rawtopiccommon.Codec, input io.Reader) (io.Rea
3636
}
3737

3838
return nil, xerrors.WithStackTrace(xerrors.Wrap(
39-
fmt.Errorf("ydb: failed decompress message with codec %v: %w", codec, PublicErrUnexpectedCodec),
39+
fmt.Errorf("ydb: failed decompress message with codec %v: %w", codec, ErrPublicUnexpectedCodec),
4040
))
4141
}
4242

internal/topic/topicreaderinternal/message.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515

1616
var errMessageWasReadEarly = xerrors.Wrap(errors.New("ydb: message was read early"))
1717

18-
// PublicErrUnexpectedCodec return when try to read message content with unknown codec
19-
var PublicErrUnexpectedCodec = errors.New("unexpected codec") //nolint:revive,stylecheck
18+
// ErrPublicUnexpectedCodec return when try to read message content with unknown codec
19+
var ErrPublicUnexpectedCodec = errors.New("unexpected codec") //nolint:revive,stylecheck
2020

2121
// PublicMessage is representation of topic message
2222
type PublicMessage struct {

internal/xcontext/context_error.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@ import (
44
"github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
55
)
66

7-
var _ error = (*ctxErr)(nil)
7+
var _ error = (*ctxError)(nil)
88

99
const (
1010
atWord = "at"
1111
fromWord = "from"
1212
)
1313

1414
func errAt(err error, skipDepth int) error {
15-
return &ctxErr{
15+
return &ctxError{
1616
err: err,
1717
stackRecord: stack.Record(skipDepth + 1),
1818
linkWord: atWord,
1919
}
2020
}
2121

2222
func errFrom(err error, from string) error {
23-
return &ctxErr{
23+
return &ctxError{
2424
err: err,
2525
stackRecord: from,
2626
linkWord: fromWord,
2727
}
2828
}
2929

30-
type ctxErr struct {
30+
type ctxError struct {
3131
err error
3232
stackRecord string
3333
linkWord string
3434
}
3535

36-
func (e *ctxErr) Error() string {
36+
func (e *ctxError) Error() string {
3737
return "'" + e.err.Error() + "' " + e.linkWord + " `" + e.stackRecord + "`"
3838
}
3939

40-
func (e *ctxErr) Unwrap() error {
40+
func (e *ctxError) Unwrap() error {
4141
return e.err
4242
}

internal/xerrors/issues.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (ii issues) String() string {
5757

5858
// NewWithIssues returns error which contains child issues
5959
func NewWithIssues(text string, issues ...error) error {
60-
err := &errorWithIssues{
60+
err := &withIssuesError{
6161
reason: text,
6262
}
6363
for i := range issues {
@@ -69,14 +69,14 @@ func NewWithIssues(text string, issues ...error) error {
6969
return err
7070
}
7171

72-
type errorWithIssues struct {
72+
type withIssuesError struct {
7373
reason string
7474
issues []error
7575
}
7676

77-
func (e *errorWithIssues) isYdbError() {}
77+
func (e *withIssuesError) isYdbError() {}
7878

79-
func (e *errorWithIssues) Error() string {
79+
func (e *withIssuesError) Error() string {
8080
var b bytes.Buffer
8181
if len(e.reason) > 0 {
8282
b.WriteString(e.reason)
@@ -95,7 +95,7 @@ func (e *errorWithIssues) Error() string {
9595
return b.String()
9696
}
9797

98-
func (e *errorWithIssues) As(target interface{}) bool {
98+
func (e *withIssuesError) As(target interface{}) bool {
9999
for _, err := range e.issues {
100100
if As(err, target) {
101101
return true
@@ -105,7 +105,7 @@ func (e *errorWithIssues) As(target interface{}) bool {
105105
return false
106106
}
107107

108-
func (e *errorWithIssues) Is(target error) bool {
108+
func (e *withIssuesError) Is(target error) bool {
109109
for _, err := range e.issues {
110110
if Is(err, target) {
111111
return true

internal/xerrors/join.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring"
77
)
88

9-
func Join(errs ...error) joinError {
9+
func Join(errs ...error) joinErrors {
1010
return errs
1111
}
1212

13-
type joinError []error
13+
type joinErrors []error
1414

15-
func (errs joinError) Error() string {
15+
func (errs joinErrors) Error() string {
1616
b := xstring.Buffer()
1717
defer b.Free()
1818
b.WriteByte('[')
@@ -27,7 +27,7 @@ func (errs joinError) Error() string {
2727
return b.String()
2828
}
2929

30-
func (errs joinError) As(target interface{}) bool {
30+
func (errs joinErrors) As(target interface{}) bool {
3131
for _, err := range errs {
3232
if As(err, target) {
3333
return true
@@ -37,7 +37,7 @@ func (errs joinError) As(target interface{}) bool {
3737
return false
3838
}
3939

40-
func (errs joinError) Is(target error) bool {
40+
func (errs joinErrors) Is(target error) bool {
4141
for _, err := range errs {
4242
if Is(err, target) {
4343
return true
@@ -47,6 +47,6 @@ func (errs joinError) Is(target error) bool {
4747
return false
4848
}
4949

50-
func (errs joinError) Unwrap() []error {
50+
func (errs joinErrors) Unwrap() []error {
5151
return errs
5252
}

internal/xerrors/join_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func TestJoin(t *testing.T) {
1212
for _, tt := range []struct {
13-
err joinError
13+
err joinErrors
1414
iss []error
1515
ass []interface{}
1616
s string

internal/xsql/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ func (c *conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (_ drive
467467
if c.currentTx != nil {
468468
return nil, xerrors.WithStackTrace(
469469
xerrors.Retryable(
470-
&ErrConnAlreadyHaveTx{
470+
&ConnAlreadyHaveTxError{
471471
currentTx: c.currentTx.ID(),
472472
},
473473
xerrors.WithDeleteSession(),

internal/xsql/errors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ var (
1414
errNotReadyConn = xerrors.Retryable(errors.New("conn not ready"), xerrors.WithDeleteSession())
1515
)
1616

17-
type ErrConnAlreadyHaveTx struct {
17+
type ConnAlreadyHaveTxError struct {
1818
currentTx string
1919
}
2020

21-
func (err *ErrConnAlreadyHaveTx) Error() string {
21+
func (err *ConnAlreadyHaveTxError) Error() string {
2222
return "conn already have an open currentTx: " + err.currentTx
2323
}
2424

25-
func (err *ErrConnAlreadyHaveTx) As(target interface{}) bool {
25+
func (err *ConnAlreadyHaveTxError) As(target interface{}) bool {
2626
switch t := target.(type) {
27-
case *ErrConnAlreadyHaveTx:
27+
case *ConnAlreadyHaveTxError:
2828
t.currentTx = err.currentTx
2929

3030
return true

0 commit comments

Comments
 (0)