@@ -25,13 +25,13 @@ func (tnterr Error) Error() string {
2525// ClientError is connection error produced by this client,
2626// i.e. connection failures or timeouts.
2727type ClientError struct {
28- Code uint32
28+ Code CodeError
2929 Msg string
3030}
3131
3232// Error converts a ClientError to a string.
3333func (clierr ClientError ) Error () string {
34- return fmt .Sprintf ("%s (0x%x)" , clierr .Msg , clierr .Code )
34+ return fmt .Sprintf ("%s (0x%x)" , clierr .Msg , uint32 ( clierr .Code ) )
3535}
3636
3737// Temporary returns true if next attempt to perform request may succeeded.
@@ -52,13 +52,22 @@ func (clierr ClientError) Temporary() bool {
5252 }
5353}
5454
55+ // CodeError is an error providing code of failure, to distinct them using errors.Is.
56+ type CodeError uint32
57+
58+ // Error converts CodeError to a string.
59+ func (err CodeError ) Error () string {
60+ return fmt .Sprintf ("0x%x" , uint32 (err ))
61+ }
62+
5563// Tarantool client error codes.
5664const (
57- ErrConnectionNotReady = 0x4000 + iota
58- ErrConnectionClosed = 0x4000 + iota
59- ErrProtocolError = 0x4000 + iota
60- ErrTimeouted = 0x4000 + iota
61- ErrRateLimited = 0x4000 + iota
62- ErrConnectionShutdown = 0x4000 + iota
63- ErrIoError = 0x4000 + iota
65+ ErrConnectionNotReady CodeError = 0x4000 + iota
66+ ErrConnectionClosed
67+ ErrProtocolError
68+ ErrTimeouted
69+ ErrRateLimited
70+ ErrConnectionShutdown
71+ ErrIoError
72+ ErrCancelledCtx
6473)
0 commit comments