Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorEqual(err1, err2 error) bool
- func ErrorNotEqual(err1, err2 error) bool
- type ErrClass
- type ErrCode
- type Error
- func (e *Error) Class() ErrClass
- func (e *Error) Code() ErrCode
- func (e *Error) Equal(err error) bool
- func (e *Error) Error() string
- func (e *Error) Gen(format string, args ...interface{}) *Error
- func (e *Error) Location() (file string, line int)
- func (e *Error) NotEqual(err error) bool
- func (e *Error) ToSQLError() *mysql.SQLError
Constants ¶
const ( CodeCommitNotInTransaction ErrCode = 1 CodeRollbackNotInTransaction = 2 CodeExecResultIsEmpty = 3 )
Executor error codes.
Variables ¶
var ( CommitNotInTransaction = ClassExecutor.New(CodeCommitNotInTransaction, "commit not in transaction") RollbackNotInTransaction = ClassExecutor.New(CodeRollbackNotInTransaction, "rollback not in transaction") ExecResultIsEmpty = ClassExecutor.New(CodeExecResultIsEmpty, "exec result is empty") MissConnectionID = ClassExpression.New(CodeMissConnectionID, "miss connection id information") )
Common base error instances.
var ( // ErrClassToMySQLCodes is the map of ErrClass to code-map. ErrClassToMySQLCodes map[ErrClass](map[ErrCode]uint16) )
Functions ¶
func ErrorEqual ¶
ErrorEqual returns a boolean indicating whether err1 is equal to err2.
func ErrorNotEqual ¶
ErrorNotEqual returns a boolean indicating whether err1 isn't equal to err2.
Types ¶
type ErrClass ¶
type ErrClass int
ErrClass represents a class of errors.
const ( ClassAutoid ErrClass = iota + 1 ClassDDL ClassDomain ClassEvaluator ClassExecutor ClassExpression ClassInspectkv ClassKV ClassMeta ClassOptimizer ClassOptimizerPlan ClassParser ClassPerfSchema ClassPrivilege ClassSchema ClassServer ClassStructure ClassVariable ClassXEval )
Error classes.
func (ErrClass) EqualClass ¶
EqualClass returns true if err is *Error with the same class.
func (ErrClass) New ¶
New creates an *Error with an error code and an error message. Usually used to create base *Error.
func (ErrClass) NotEqualClass ¶
NotEqualClass returns true if err is not *Error with the same class.
type ErrCode ¶
type ErrCode int
ErrCode represents a specific error type in a error class. Same error code can be used in different error classes.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error implements error interface and adds integer Class and Code, so errors with different message can be compared.
func (*Error) Gen ¶
Gen generates a new *Error with the same class and code, and a new formatted message.
func (*Error) Location ¶
Location returns the location where the error is created, implements juju/errors locationer interface.
func (*Error) ToSQLError ¶
ToSQLError convert Error to mysql.SQLError.