Documentation ¶
Index ¶
- Variables
- func Call(fn func() error)
- func ErrorEqual(err1, err2 error) bool
- func ErrorNotEqual(err1, err2 error) bool
- func Log(err error)
- func MustNil(err error, closeFuns ...func())
- func ToSQLError(e *Error) *mysql.SQLError
- type ErrClass
- func (ec ErrClass) EqualClass(err error) bool
- func (ec ErrClass) New(code ErrCode, message string) *Error
- func (ec ErrClass) NewStd(code ErrCode) *Error
- func (ec ErrClass) NewStdErr(code ErrCode, message string, desc string, workaround string) *Error
- func (ec ErrClass) NotEqualClass(err error) bool
- func (ec ErrClass) String() string
- func (ec ErrClass) Synthesize(code ErrCode, message string) *Error
- type ErrCode
- type Error
Constants ¶
This section is empty.
Variables ¶
var ( ClassAutoid = RegisterErrorClass(1, "autoid") ClassDDL = RegisterErrorClass(2, "ddl") ClassDomain = RegisterErrorClass(3, "domain") ClassEvaluator = RegisterErrorClass(4, "evaluator") ClassExecutor = RegisterErrorClass(5, "executor") ClassExpression = RegisterErrorClass(6, "expression") ClassAdmin = RegisterErrorClass(7, "admin") ClassKV = RegisterErrorClass(8, "kv") ClassMeta = RegisterErrorClass(9, "meta") ClassOptimizer = RegisterErrorClass(10, "planner") ClassParser = RegisterErrorClass(11, "parser") ClassPerfSchema = RegisterErrorClass(12, "perfschema") ClassPrivilege = RegisterErrorClass(13, "privilege") ClassSchema = RegisterErrorClass(14, "schema") ClassServer = RegisterErrorClass(15, "server") ClassStructure = RegisterErrorClass(16, "structure") ClassVariable = RegisterErrorClass(17, "variable") ClassXEval = RegisterErrorClass(18, "xeval") ClassTable = RegisterErrorClass(19, "table") ClassTypes = RegisterErrorClass(20, "types") ClassGlobal = RegisterErrorClass(21, "global") ClassMockTikv = RegisterErrorClass(22, "mocktikv") ClassJSON = RegisterErrorClass(23, "json") ClassTiKV = RegisterErrorClass(24, "tikv") ClassSession = RegisterErrorClass(25, "session") ClassPlugin = RegisterErrorClass(26, "plugin") ClassUtil = RegisterErrorClass(27, "util") )
Error classes.
var ( // ErrClassToMySQLCodes is the map of ErrClass to code-set. ErrClassToMySQLCodes = make(map[ErrClass]map[ErrCode]struct{}) ErrCritical = ClassGlobal.New(CodeExecResultIsEmpty, "critical error %v") ErrResultUndetermined = ClassGlobal.New(CodeResultUndetermined, "execution result undetermined") )
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.
func MustNil ¶
func MustNil(err error, closeFuns ...func())
MustNil cleans up and fatals if err is not nil.
func ToSQLError ¶
ToSQLError convert Error to mysql.SQLError.
Types ¶
type ErrClass ¶
type ErrClass int
ErrClass represents a class of errors.
func GetErrClass ¶
func RegisterErrorClass ¶
RegisterErrorClass registers new error class for terror.
func (ErrClass) EqualClass ¶
EqualClass returns true if err is *Error with the same class.
func (ErrClass) New ¶
New defines an *Error with an error code and an error message. Usually used to create base *Error. Attention: this method is not goroutine-safe and usually be used in global variable initializer
func (ErrClass) NewStd ¶
NewStd calls New using the standard message for the error code Attention: this method is not goroutine-safe and usually be used in global variable initializer
func (ErrClass) NewStdErr ¶
NewStdErr defines an *Error with an error code, an error message and workaround to create standard error. Attention: this method is not goroutine-safe and usually be used in global variable initializer
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.
const ( // CodeUnknown is for errors of unknown reason. CodeUnknown ErrCode = -1 // CodeExecResultIsEmpty indicates execution result is empty. CodeExecResultIsEmpty ErrCode = 3 // CodeMissConnectionID indicates connection id is missing. CodeMissConnectionID ErrCode = 1 // CodeResultUndetermined indicates the sql execution result is undetermined. CodeResultUndetermined ErrCode = 2 )