api: redesign errors around errors.Is and errors.As#589
Open
api: redesign errors around errors.Is and errors.As#589
Conversation
1b2ecbc to
26bfbbf
Compare
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
26bfbbf to
c9ea279
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reworks
go-tarantoolerror types to fit Go's standarderrors.Is/errors.Aspatterns.tarantool.Error→tarantool.ServerError. The old name read like "any error in this package" and confused users.uint32client error codes (ErrConnectionNotReady,ErrConnectionClosed, ...) are now package-levelerrorsentinels matched viaerrors.Is. Numeric form is preserved as typedtarantool.ClientErrorCodeconstants (CodeConnectionClosed, ...).ClientErrorgainsCause error+Unwrap() []error. I/O failures now wrap the underlyingneterror instead of stringifying it, soerrors.Asreaches it.ErrRetryable) joined into the chain.IsRetryable(err)is a one-lineerrors.Is. DeprecatedClientError.Temporary()removed (no callers,net.Error.Temporarydeprecated since Go 1.18).connection.go/response.goswitched tonewClientError/ServerError. Tests inbox,arrow, and the root package migrated from typeassertions toerrors.As/errors.Is.%xformatting bug oniproto.ErrorinServerError.Error().Closes #469