Skip to content

Commit

Permalink
add explicit initialization of fields of structures in internal/xerrors
Browse files Browse the repository at this point in the history
  • Loading branch information
kozyrev-m committed Apr 15, 2024
1 parent 14511ab commit 4140b14
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions internal/xerrors/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (ii issues) String() string {
func NewWithIssues(text string, issues ...error) error {
err := &withIssuesError{
reason: text,
issues: nil,
}
for i := range issues {
if issues[i] != nil {
Expand Down
11 changes: 8 additions & 3 deletions internal/xerrors/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ func (e *operationOption) applyToOperationError(oe *operationError) {
// FromOperation must use as `Operation(FromOperation(operation.Status))`
func FromOperation(operation operation.Status) *operationOption {
return &operationOption{
code: operation.GetStatus(),
issues: operation.GetIssues(),
code: operation.GetStatus(),
issues: operation.GetIssues(),
address: "",
traceID: "",
}
}

Expand All @@ -95,7 +97,10 @@ type oeOpt interface {

func Operation(opts ...oeOpt) error {
oe := &operationError{
code: Ydb.StatusIds_STATUS_CODE_UNSPECIFIED,
code: Ydb.StatusIds_STATUS_CODE_UNSPECIFIED,
issues: nil,
address: "",
traceID: "",
}
for _, opt := range opts {
if opt != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/xerrors/retryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func Retryable(err error, opts ...RetryableErrorOption) error {
re = &retryableError{
err: err,
name: "CUSTOM",
backoffType: backoff.TypeNoBackoff,
code: -1,
isRetryObjectValid: true,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/xerrors/stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func WithStackTrace(err error, opts ...withStackTraceOption) error {
if err == nil {
return nil
}
options := withStackTraceOptions{}
options := withStackTraceOptions{skipDepth: 0}
for _, opt := range opts {
if opt != nil {
opt(&options)
Expand Down
18 changes: 12 additions & 6 deletions internal/xerrors/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ func Transport(err error, opts ...teOpt) error {
}
if s, ok := grpcStatus.FromError(err); ok {
te = &transportError{
status: s,
err: err,
status: s,
err: err,
address: "",
traceID: "",
}
} else {
te = &transportError{
status: grpcStatus.New(grpcCodes.Unknown, stack.Record(1)),
err: err,
status: grpcStatus.New(grpcCodes.Unknown, stack.Record(1)),
err: err,
address: "",
traceID: "",
}
}
for _, opt := range opts {
Expand Down Expand Up @@ -194,8 +198,10 @@ func TransportError(err error) Error {
}
if s, ok := grpcStatus.FromError(err); ok {
return &transportError{
status: s,
err: err,
status: s,
err: err,
address: "",
traceID: "",
}
}

Expand Down

0 comments on commit 4140b14

Please sign in to comment.