errors

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMasterConn  = errors.New("no master connection")
	ErrNoSlaveConn   = errors.New("no slave connection")
	ErrNoDefaultNode = errors.New("no default node")
	ErrNoMasterDB    = errors.New("no master database")
	ErrNoSlaveDB     = errors.New("no slave database")
	ErrNoDatabase    = errors.New("no database")

	ErrMasterDown    = errors.New("master is down")
	ErrSlaveDown     = errors.New("slave is down")
	ErrDatabaseClose = errors.New("database is close")
	ErrConnIsNil     = errors.New("connection is nil")
	ErrConnIsFull    = errors.New("connection is full")
	ErrMaxPoolIsFull = errors.New("db connection pool is full")
	ErrBadConn       = errors.New("connection was bad")
	ErrIgnoreSQL     = errors.New("ignore this sql")

	ErrAddressNull     = errors.New("address is nil")
	ErrInvalidArgument = errors.New("argument is invalid")
	ErrInvalidCharset  = errors.New("charset is invalid")
	ErrCmdUnsupport    = errors.New("command unsupport")

	ErrLocationsCount = errors.New("locations count is not equal")
	ErrNoCriteria     = errors.New("plan have no criteria")
	ErrNoRouteNode    = errors.New("no route node")
	ErrResultNil      = errors.New("result is nil")
	ErrSumColumnType  = errors.New("sum column type error")
	ErrSelectInInsert = errors.New("select in insert not allowed")
	ErrInsertInMulti  = errors.New("insert in multi node")
	ErrUpdateInMulti  = errors.New("update in multi node")
	ErrDeleteInMulti  = errors.New("delete in multi node")
	ErrReplaceInMulti = errors.New("replace in multi node")
	ErrExecInMulti    = errors.New("exec in multi node")
	ErrTransInMulti   = errors.New("transaction in multi node")

	ErrNoPlan           = errors.New("statement have no plan")
	ErrNoPlanRule       = errors.New("statement have no plan rule")
	ErrUpdateKey        = errors.New("routing key in update expression")
	ErrStmtConvert      = errors.New("statement fail to convert")
	ErrExprConvert      = errors.New("expr fail to convert")
	ErrConnNotEqual     = errors.New("the length of conns not equal sqls")
	ErrKeyOutOfRange    = errors.New("shard key not in key range")
	ErrMultiShard       = errors.New("insert or replace has multiple shard targets")
	ErrIRNoColumns      = errors.New("insert or replace must specify columns")
	ErrIRNoShardingKey  = errors.New("insert or replace not contain sharding key")
	ErrColsLenNotMatch  = errors.New("insert or replace cols and values length not match")
	ErrDateIllegal      = errors.New("date format illegal")
	ErrDateRangeIllegal = errors.New("date range format illegal")
	ErrDateRangeCount   = errors.New("date range count is not equal")
	ErrSlaveExist       = errors.New("slave has exist")
	ErrSlaveNotExist    = errors.New("slave has not exist")
	ErrBlackSqlExist    = errors.New("black sql has exist")
	ErrBlackSqlNotExist = errors.New("black sql has not exist")
	ErrInsertTooComplex = errors.New("insert is too complex")
	ErrSQLNULL          = errors.New("sql is null")

	ErrInternalServer = errors.New("internal server error")

	ErrUnsupportDbType      = errors.New("unsupport db type")
	ErrParseHe3MetaConninfo = errors.New("he3_meta_conninfo format not correct")
)

Functions

func ErrFormat

func ErrFormat(str string, args ...interface{}) error

func ErrFormatStr

func ErrFormatStr(str string, args ...interface{}) error

func SafeToRetry

func SafeToRetry(err error) bool

SafeToRetry checks if the err is guaranteed to have occurred before sending any data to the server.

func Timeout

func Timeout(err error) bool

Timeout checks if err was was caused by a timeout. To be specific, it is true if err was caused within pgconn by a context.Canceled, context.DeadlineExceeded or an implementer of net.Error where Timeout() is true.

Types

type PgError

type PgError struct {
	Severity         string
	Code             string
	Message          string
	Detail           string
	Hint             string
	Position         int32
	InternalPosition int32
	InternalQuery    string
	Where            string
	SchemaName       string
	TableName        string
	ColumnName       string
	DataTypeName     string
	ConstraintName   string
	File             string
	Line             int32
	Routine          string
}

PgError represents an error reported by the PostgreSQL server. See http://www.postgresql.org/docs/11/static/protocol-error-fields.html for detailed field description.

func ErrorResponseToPgError

func ErrorResponseToPgError(msg *pgproto3.ErrorResponse) *PgError

ErrorResponseToPgError converts a wire protocol error message to a *PgError.

func (*PgError) Error

func (pe *PgError) Error() string

func (*PgError) SQLState

func (pe *PgError) SQLState() string

SQLState returns the SQLState of the error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL