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

     1  package xsql
     2  
     3  import (
     4  	"database/sql/driver"
     5  	"errors"
     6  
     7  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
     8  )
     9  
    10  var (
    11  	ErrUnsupported     = driver.ErrSkip
    12  	errDeprecated      = driver.ErrSkip
    13  	errConnClosedEarly = xerrors.Retryable(errors.New("conn closed early"), xerrors.WithDeleteSession())
    14  	errNotReadyConn    = xerrors.Retryable(errors.New("conn not ready"), xerrors.WithDeleteSession())
    15  )
    16  
    17  type ConnAlreadyHaveTxError struct {
    18  	currentTx string
    19  }
    20  
    21  func (err *ConnAlreadyHaveTxError) Error() string {
    22  	return "conn already have an open currentTx: " + err.currentTx
    23  }
    24  
    25  func (err *ConnAlreadyHaveTxError) As(target interface{}) bool {
    26  	switch t := target.(type) {
    27  	case *ConnAlreadyHaveTxError:
    28  		t.currentTx = err.currentTx
    29  
    30  		return true
    31  	default:
    32  		return false
    33  	}
    34  }