terror

package
v0.0.0-...-14e0149 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCritical           = ClassGlobal.New(CodeExecResultIsEmpty, "critical error %v")
	ErrResultUndetermined = ClassGlobal.New(CodeResultUndetermined, "execution result undetermined")
)

Global error instances.

View Source
var (
	// ErrClassToMySQLCodes is the map of ErrClass to code-map.
	ErrClassToMySQLCodes map[ErrClass](map[ErrCode]uint16)
)

Functions

func ErrorEqual

func ErrorEqual(err1, err2 error) bool

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

func ErrorNotEqual

func ErrorNotEqual(err1, err2 error) bool

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
	ClassTable
	ClassTypes
	ClassGlobal
	ClassMockTikv
	ClassJSON
)

Error classes.

func (ErrClass) EqualClass

func (ec ErrClass) EqualClass(err error) bool

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

func (ErrClass) New

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

New creates an *Error with an error code and an error message. Usually used to create base *Error.

func (ErrClass) NotEqualClass

func (ec ErrClass) NotEqualClass(err error) bool

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

func (ErrClass) String

func (ec ErrClass) String() string

String implements fmt.Stringer interface.

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 = 3

	// CodeMissConnectionID indicates connection id is missing.
	CodeMissConnectionID ErrCode = 1

	// CodeResultUndetermined indicates the sql execution result is undetermined.
	CodeResultUndetermined ErrCode = 2
)

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

func (e *Error) Class() ErrClass

Class returns ErrClass

func (*Error) Code

func (e *Error) Code() ErrCode

Code returns ErrCode

func (*Error) Equal

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

Equal checks if err is equal to e.

func (*Error) Error

func (e *Error) Error() string

Error implements error interface.

func (*Error) FastGen

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

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

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

func (*Error) GenByArgs

func (e *Error) GenByArgs(args ...interface{}) *Error

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

func (*Error) Location

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

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

MarshalJSON implements json.Marshaler interface.

func (*Error) NotEqual

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

NotEqual checks if err is not equal to e.

func (*Error) ToSQLError

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

ToSQLError convert Error to mysql.SQLError.

func (*Error) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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