github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/xsql/badconn/badconn.go (about) 1 package badconn 2 3 import ( 4 "database/sql/driver" 5 "io" 6 7 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" 8 ) 9 10 type Error struct { 11 err error 12 } 13 14 func (e Error) Origin() error { 15 return e.err 16 } 17 18 func (e Error) Error() string { 19 return e.err.Error() 20 } 21 22 func (e Error) Is(err error) bool { 23 //nolint:nolintlint 24 if err == driver.ErrBadConn { //nolint:errorlint 25 return true 26 } 27 28 return xerrors.Is(e.err, err) 29 } 30 31 func (e Error) As(target interface{}) bool { 32 switch target.(type) { 33 case Error, *Error: 34 return true 35 default: 36 return xerrors.As(e.err, target) 37 } 38 } 39 40 func Map(err error) error { 41 switch { 42 case err == nil: 43 return nil 44 case xerrors.Is(err, io.EOF): 45 return io.EOF 46 case xerrors.MustDeleteSession(err): 47 return Error{err: err} 48 default: 49 return err 50 } 51 }