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

     1  package xerrors
     2  
     3  import (
     4  	"errors"
     5  )
     6  
     7  type isYdbError interface {
     8  	isYdbError()
     9  }
    10  
    11  func IsYdb(err error) bool {
    12  	var e isYdbError
    13  
    14  	return errors.As(err, &e)
    15  }
    16  
    17  type ydbError struct {
    18  	err error
    19  }
    20  
    21  func (e *ydbError) isYdbError() {}
    22  
    23  func (e *ydbError) Error() string {
    24  	return e.err.Error()
    25  }
    26  
    27  func (e *ydbError) Unwrap() error {
    28  	return e.err
    29  }
    30  
    31  // Wrap makes internal ydb error
    32  func Wrap(err error) error {
    33  	return &ydbError{err: err}
    34  }