github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/xerrors/check.go (about)

     1  package xerrors
     2  
     3  import (
     4  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/backoff"
     5  )
     6  
     7  // Check returns retry mode for err.
     8  func Check(err error) (
     9  	code int64,
    10  	errType Type,
    11  	backoffType backoff.Type,
    12  	deleteSession bool,
    13  ) {
    14  	if err == nil {
    15  		return -1,
    16  			TypeNoError,
    17  			backoff.TypeNoBackoff,
    18  			false
    19  	}
    20  	var e Error
    21  	if As(err, &e) {
    22  		return int64(e.Code()), e.Type(), e.BackoffType(), e.MustDeleteSession()
    23  	}
    24  
    25  	return -1,
    26  		TypeNonRetryable, // unknown errors are not retryable
    27  		backoff.TypeNoBackoff,
    28  		false
    29  }
    30  
    31  func MustDeleteSession(err error) bool {
    32  	var e Error
    33  	if As(err, &e) {
    34  		return e.MustDeleteSession()
    35  	}
    36  
    37  	return false
    38  }