errors

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: BSD-3-Clause Imports: 4 Imported by: 20

Documentation

Index

Constants

View Source
const (

	// 系统级别的错误,包括IO异常,空指针,等
	ErrorSystem = _baseError | 0x1000000
	// 业务相关的异常
	ErrorMessage = _baseError | 0x2000000

	ErrorMessageNotFount = ErrorMessage | 0x1

	ErrorSystemInternal = ErrorSystem | 0x1
	// ErrCodeScopeBaseRPC RPC级别的 ErrCode
	ErrorSystemDB = ErrorSystem | 0x2

	ErrorSystemRedis = ErrorSystem | 0x3
	// RPC错误,包含编解码
	ErrorSystemRPC = ErrorSystem | 0x4

	ErrorSystemNet = ErrorSystem | 0x5
)

Variables

This section is empty.

Functions

func EqualError

func EqualError(srcCode, targetCode int64) bool

func ErrorToJson

func ErrorToJson(err Error) string

func IsBaseError

func IsBaseError(err error) bool

func IsBaseErrorCode

func IsBaseErrorCode(code int64) bool

func IsDBError

func IsDBError(err error) bool

func IsInternalError

func IsInternalError(err error) bool

func IsMessageError

func IsMessageError(err error) bool

func IsNetError

func IsNetError(err error) bool

func IsNotFountError

func IsNotFountError(err error) bool

func IsRPCError

func IsRPCError(err error) bool

func IsRedisErro

func IsRedisErro(err error) bool

func IsSystemError

func IsSystemError(err error) bool

func NamedScope

func NamedScope(name string) zap.Field

Types

type Error

type Error interface {
	error
	GetCode() int64
	GetFields(fields ...zap.Field) []zap.Field
	GetFieldsWithCause(fields ...zap.Field) []zap.Field
	FormatRPCError() string
	Is(Error) bool
	ToError() error
}

Error 基础的错误接口

func BuildError

func BuildError(errorCode int64, message string) Error

func ConverError

func ConverError(err error) Error

func ConverUnknowError

func ConverUnknowError(err interface{}) Error

func MessageError

func MessageError(message string) Error

func NewNetError

func NewNetError(err NetError) Error

func ParseError

func ParseError(jsonStr string) Error

func ParseErrorFromJSON

func ParseErrorFromJSON(data []byte) Error

ParseErrorFromJSON 从 Jons数据解析出 Error 对象

func SystemError

func SystemError(message string) Error

func WrappedError

func WrappedError(errorCode int64, err error) Error

func WrappedMessageError

func WrappedMessageError(err error) Error

func WrappedSystemError

func WrappedSystemError(err error) Error

type NetError

type NetError interface {
	Error() string
	Timeout() bool
	Temporary() bool
}

Jump to

Keyboard shortcuts

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