Skip to content

api: redesign errors around errors.Is and errors.As#589

Open
bigbes wants to merge 1 commit intomasterfrom
bigbes/gh-469-error-redesign
Open

api: redesign errors around errors.Is and errors.As#589
bigbes wants to merge 1 commit intomasterfrom
bigbes/gh-469-error-redesign

Conversation

@bigbes
Copy link
Copy Markdown
Collaborator

@bigbes bigbes commented May 5, 2026

Reworks go-tarantool error types to fit Go's standard errors.Is / errors.As patterns.

  • tarantool.Errortarantool.ServerError. The old name read like "any error in this package" and confused users.
  • The seven legacy uint32 client error codes (ErrConnectionNotReady, ErrConnectionClosed, ...) are now package-level error sentinels matched via errors.Is. Numeric form is preserved as typed tarantool.ClientErrorCode constants (CodeConnectionClosed, ...).
  • ClientError gains Cause error + Unwrap() []error. I/O failures now wrap the underlying net error instead of stringifying it, so errors.As reaches it.
  • Retryability is expressed as a sentinel (ErrRetryable) joined into the chain. IsRetryable(err) is a one-line errors.Is. Deprecated ClientError.Temporary() removed (no callers, net.Error.Temporary deprecated since Go 1.18).
  • Internal callers in connection.go/response.go switched to newClientError / ServerError. Tests in box, arrow, and the root package migrated from typeassertions to errors.As / errors.Is.
  • Drive-by: fixed a pre-existing %x formatting bug on iproto.Error in ServerError.Error().

Closes #469

@bigbes bigbes force-pushed the bigbes/gh-469-error-redesign branch from 1b2ecbc to 26bfbbf Compare May 5, 2026 09:49
@bigbes bigbes marked this pull request as draft May 5, 2026 09:50
Rename tarantool.Error to ServerError, promote the seven legacy uint32
client error codes to package-level error sentinels (ErrConnectionClosed,
ErrTimeouted, ...) and expose their numeric form as a typed
ClientErrorCode (CodeConnectionClosed, ...). ClientError gains a Cause
field plus Unwrap() []error so errors.Is matches the sentinel and
errors.As reaches the underlying net error. Retryability is expressed as
a sentinel (ErrRetryable) joined into the chain; IsRetryable wraps
errors.Is. The deprecated Temporary() method is removed.

Internal callers in connection.go and response.go switched to
newClientError / ServerError; I/O failures now wrap the original error
instead of stringifying it. Tests in box, arrow, and the root package
were migrated from typeassertions to errors.As / errors.Is.

Also fixes a pre-existing %x formatting bug on iproto.Error in
ServerError.Error().

Closes #469
@bigbes bigbes force-pushed the bigbes/gh-469-error-redesign branch from 26bfbbf to c9ea279 Compare May 5, 2026 10:06
@bigbes bigbes marked this pull request as ready for review May 5, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v3: new design for go-tarantool errors

1 participant