@@ -28,29 +28,24 @@ func IsTimeoutError(err error) bool {
2828 return errors .IsTimeoutError (err )
2929}
3030
31- func IsTransportError (err error ) bool {
32- return TransportErrorDescription (err ) != nil
33- }
34-
35- func IsTransportErrorCode (err error , codes ... int32 ) bool {
36- d := TransportErrorDescription (err )
37- if d == nil {
38- return false
39- }
40- for _ , code := range codes {
41- if d .Code () == code {
42- return true
43- }
44- }
45- return false
31+ func IsTransportError (err error , codes ... int32 ) bool {
32+ return errors .IsTransportError (
33+ err ,
34+ func () (cc []errors.TransportErrorCode ) {
35+ for _ , code := range codes {
36+ cc = append (cc , errors .TransportErrorCode (code ))
37+ }
38+ return cc
39+ }()... ,
40+ )
4641}
4742
4843func IsTransportErrorCancelled (err error ) bool {
49- return IsTransportErrorCode (err , int32 (errors .TransportErrorCanceled ))
44+ return IsTransportError (err , int32 (errors .TransportErrorCanceled ))
5045}
5146
5247func IsTransportErrorResourceExhausted (err error ) bool {
53- return IsTransportErrorCode (err , int32 (errors .TransportErrorResourceExhausted ))
48+ return IsTransportError (err , int32 (errors .TransportErrorResourceExhausted ))
5449}
5550
5651type Error interface {
@@ -72,21 +67,16 @@ func IsYdbError(err error) bool {
7267 return IsTransportError (err ) || IsOperationError (err )
7368}
7469
75- func IsOperationError (err error ) bool {
76- return OperationErrorDescription (err ) != nil
77- }
78-
79- func IsOperationErrorCode (err error , codes ... int32 ) bool {
80- d := OperationErrorDescription (err )
81- if d == nil {
82- return false
83- }
84- for _ , code := range codes {
85- if d .Code () == code {
86- return true
87- }
88- }
89- return false
70+ func IsOperationError (err error , codes ... int32 ) bool {
71+ return errors .IsOpError (
72+ err ,
73+ func () (cc []errors.StatusCode ) {
74+ for _ , code := range codes {
75+ cc = append (cc , errors .StatusCode (code ))
76+ }
77+ return cc
78+ }()... ,
79+ )
9080}
9181
9282func OperationErrorDescription (err error ) Error {
@@ -98,23 +88,23 @@ func OperationErrorDescription(err error) Error {
9888}
9989
10090func IsOperationErrorOverloaded (err error ) bool {
101- return IsOperationErrorCode (err , int32 (errors .StatusOverloaded ))
91+ return IsOperationError (err , int32 (errors .StatusOverloaded ))
10292}
10393
10494func IsOperationErrorUnavailable (err error ) bool {
105- return IsOperationErrorCode (err , int32 (errors .StatusUnavailable ))
95+ return IsOperationError (err , int32 (errors .StatusUnavailable ))
10696}
10797
10898func IsOperationErrorAlreadyExistsError (err error ) bool {
109- return IsOperationErrorCode (err , int32 (errors .StatusAlreadyExists ))
99+ return IsOperationError (err , int32 (errors .StatusAlreadyExists ))
110100}
111101
112102func IsOperationErrorNotFoundError (err error ) bool {
113- return IsOperationErrorCode (err , int32 (errors .StatusNotFound ))
103+ return IsOperationError (err , int32 (errors .StatusNotFound ))
114104}
115105
116106func IsOperationErrorSchemeError (err error ) bool {
117- return IsOperationErrorCode (err , int32 (errors .StatusSchemeError ))
107+ return IsOperationError (err , int32 (errors .StatusSchemeError ))
118108}
119109
120110func IsRatelimiterAcquireError (err error ) bool {
0 commit comments