1 Star 1 Fork 0

bigbase/pg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
error.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
package pg
import (
"io"
"net"
"gopkg.in/pg.v5/internal"
)
var (
ErrNoRows = internal.ErrNoRows
ErrMultiRows = internal.ErrMultiRows
errSSLNotSupported = internal.Errorf("pg: SSL is not enabled on the server")
errClosed = internal.Errorf("pg: database is closed")
errTxDone = internal.Errorf("pg: transaction has already been committed or rolled back")
errStmtClosed = internal.Errorf("pg: statement is closed")
errListenerClosed = internal.Errorf("pg: listener is closed")
)
type Error interface {
Field(byte) string
IntegrityViolation() bool
}
var _ Error = (*internal.PGError)(nil)
func isBadConn(err error, allowTimeout bool) bool {
if err == nil {
return false
}
if _, ok := err.(internal.Error); ok {
return false
}
if pgErr, ok := err.(Error); ok && pgErr.Field('S') != "FATAL" {
return false
}
if allowTimeout {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
return false
}
}
return true
}
func isNetworkError(err error) bool {
if err == io.EOF {
return true
}
_, ok := err.(net.Error)
return ok
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bigbase/pg.git
git@gitee.com:bigbase/pg.git
bigbase
pg
pg
v5.0.12

搜索帮助