parser: github.com/pingcap/parser/terror Index | Files

package terror

import "github.com/pingcap/parser/terror"

Index

Package Files

terror.go

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")
)

func Call Uses

func Call(fn func() error)

Call executes a function and checks the returned err.

func ErrorEqual Uses

func ErrorEqual(err1, err2 error) bool

ErrorEqual returns a boolean indicating whether err1 is equal to err2.

func ErrorNotEqual Uses

func ErrorNotEqual(err1, err2 error) bool

ErrorNotEqual returns a boolean indicating whether err1 isn't equal to err2.

func Log Uses

func Log(err error)

Log logs the error if it is not nil.

func MustNil Uses

func MustNil(err error, closeFuns ...func())

MustNil cleans up and fatals if err is not nil.

type ErrClass Uses

type ErrClass int

ErrClass represents a class of errors.

func RegisterErrorClass Uses

func RegisterErrorClass(classCode int, desc string) ErrClass

RegisterErrorClass registers new error class for terror.

func (ErrClass) EqualClass Uses

func (ec ErrClass) EqualClass(err error) bool

EqualClass returns true if err is *Error with the same class.

func (ErrClass) New Uses

func (ec ErrClass) New(code ErrCode, message string) *Error

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 Uses

func (ec ErrClass) NewStd(code ErrCode) *Error

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) NotEqualClass Uses

func (ec ErrClass) NotEqualClass(err error) bool

NotEqualClass returns true if err is not *Error with the same class.

func (ErrClass) String Uses

func (ec ErrClass) String() string

String implements fmt.Stringer interface.

func (ErrClass) Synthesize Uses

func (ec ErrClass) Synthesize(code ErrCode, message string) *Error

Synthesize synthesizes an *Error in the air it didn't register error into ErrClassToMySQLCodes so it's goroutine-safe and often be used to create Error came from other systems like TiKV.

type ErrCode Uses

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
)

type Error Uses

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) Class Uses

func (e *Error) Class() ErrClass

Class returns ErrClass

func (*Error) Code Uses

func (e *Error) Code() ErrCode

Code returns ErrCode

func (*Error) Equal Uses

func (e *Error) Equal(err error) bool

Equal checks if err is equal to e.

func (*Error) Error Uses

func (e *Error) Error() string

Error implements error interface.

func (*Error) FastGen Uses

func (e *Error) FastGen(format string, args ...interface{}) error

FastGen generates a new *Error with the same class and code, and a new formatted message. This will not call runtime.Caller to get file and line.

func (*Error) FastGenByArgs Uses

func (e *Error) FastGenByArgs(args ...interface{}) error

FastGen generates a new *Error with the same class and code, and a new arguments. This will not call runtime.Caller to get file and line.

func (*Error) GenWithStack Uses

func (e *Error) GenWithStack(format string, args ...interface{}) error

GenWithStack generates a new *Error with the same class and code, and a new formatted message.

func (*Error) GenWithStackByArgs Uses

func (e *Error) GenWithStackByArgs(args ...interface{}) error

GenWithStackByArgs generates a new *Error with the same class and code, and new arguments.

func (*Error) Location Uses

func (e *Error) Location() (file string, line int)

Location returns the location where the error is created, implements juju/errors locationer interface.

func (*Error) MarshalJSON Uses

func (e *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Error) NotEqual Uses

func (e *Error) NotEqual(err error) bool

NotEqual checks if err is not equal to e.

func (*Error) ToSQLError Uses

func (e *Error) ToSQLError() *mysql.SQLError

ToSQLError convert Error to mysql.SQLError.

func (*Error) UnmarshalJSON Uses

func (e *Error) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

Package terror imports 7 packages (graph) and is imported by 397 packages. Updated 2020-04-23. Refresh now. Tools for package owners.