@@ -10,60 +10,78 @@ import (
1010 "github.com/ydb-platform/ydb-go-sdk/v3/ratelimiter"
1111)
1212
13+ // IterateByIssues helps to iterate over internal issues of operation error
1314func IterateByIssues (err error , it func (message string , code Ydb.StatusIds_StatusCode , severity uint32 )) {
1415 xerrors .IterateByIssues (err , it )
1516}
1617
18+ // IsTimeoutError checks whether given err is a some timeout error (context, transport or operation)
1719func IsTimeoutError (err error ) bool {
1820 return xerrors .IsTimeoutError (err )
1921}
2022
23+ // IsTransportError checks whether given err is a transport (grpc) error
2124func IsTransportError (err error , codes ... grpcCodes.Code ) bool {
2225 return xerrors .IsTransportError (err , codes ... )
2326}
2427
28+ // Error is an interface of error which reports about error code and error name
2529type Error xerrors.Error
2630
31+ // TransportError checks when given error is a transport error and returns description of transport error
2732func TransportError (err error ) Error {
2833 return xerrors .TransportError (err )
2934}
3035
36+ // IsYdbError reports when given error is and ydb error (transport, operation or internal driver error)
3137func IsYdbError (err error ) bool {
3238 return xerrors .IsYdb (err )
3339}
3440
41+ // IsOperationError reports whether any error is an operation error with one of passed codes
42+ // If codes not defined IsOperationError returns true on error is an operation error
3543func IsOperationError (err error , codes ... Ydb.StatusIds_StatusCode ) bool {
3644 return xerrors .IsOperationError (err , codes ... )
3745}
3846
47+ // OperationError returns operation error description
48+ // If given err is not an operation error - returns nil
3949func OperationError (err error ) Error {
4050 return xerrors .OperationError (err )
4151}
4252
53+ // IsOperationErrorOverloaded checks whether given err is an operation error with code Overloaded
4354func IsOperationErrorOverloaded (err error ) bool {
4455 return IsOperationError (err , Ydb .StatusIds_OVERLOADED )
4556}
4657
58+ // IsOperationErrorUnavailable checks whether given err is an operation error with code Unavailable
4759func IsOperationErrorUnavailable (err error ) bool {
4860 return IsOperationError (err , Ydb .StatusIds_UNAVAILABLE )
4961}
5062
63+ // IsOperationErrorAlreadyExistsError checks whether given err is an operation error with code AlreadyExistsError
5164func IsOperationErrorAlreadyExistsError (err error ) bool {
5265 return IsOperationError (err , Ydb .StatusIds_ALREADY_EXISTS )
5366}
5467
68+ // IsOperationErrorNotFoundError checks whether given err is an operation error with code NotFoundError
5569func IsOperationErrorNotFoundError (err error ) bool {
5670 return IsOperationError (err , Ydb .StatusIds_NOT_FOUND )
5771}
5872
73+ // IsOperationErrorSchemeError checks whether given err is an operation error with code SchemeError
5974func IsOperationErrorSchemeError (err error ) bool {
6075 return IsOperationError (err , Ydb .StatusIds_SCHEME_ERROR )
6176}
6277
78+ // IsRatelimiterAcquireError checks whether given err is an ratelimiter acquire error
6379func IsRatelimiterAcquireError (err error ) bool {
6480 return ratelimiterErrors .IsAcquireError (err )
6581}
6682
83+ // ToRatelimiterAcquireError casts given err to ratelimiter.AcquireError
84+ // If given err is not ratelimiter acquire error - returns nil
6785func ToRatelimiterAcquireError (err error ) ratelimiter.AcquireError {
6886 return ratelimiterErrors .ToAcquireError (err )
6987}
0 commit comments