errors

package
v0.21.18 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: GPL-3.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error error define

func (*Error) Error

func (p *Error) Error() string

func (*Error) FullError

func (p *Error) FullError() string

FullError 全部错误信息

func (*Error) ID

func (p *Error) ID() string

ID 返回ID

func (*Error) Message

func (p *Error) Message() string

Message 信息

func (*Error) Namespace

func (p *Error) Namespace() string

Namespace 错误的域

type ErrorCode

type ErrorCode interface {
	SimpleError
	Code() uint64
	Context() ErrorContext
	Append(err ...error) ErrorCode
	WithContext(k string, v interface{}) ErrorCode
}

ErrorCode Error functions

func NewErrorCode

func NewErrorCode(ofs ...OptionFunc) ErrorCode

NewErrorCode get a new error code

type ErrorCodeTmpl

type ErrorCodeTmpl struct {
	// contains filtered or unexported fields
}

ErrorCodeTmpl error code template

func TN

func TN(namespace string, code uint64, message string) *ErrorCodeTmpl

TN returns a new error code template

func (*ErrorCodeTmpl) New

func (p *ErrorCodeTmpl) New(opts ...Option) ErrorCode

New ErrorCodeTmpl new error code by template

type ErrorContext

type ErrorContext map[string]interface{}

ErrorContext map contexts

func (ErrorContext) Error

func (p ErrorContext) Error() string

type ErrorOptions

type ErrorOptions struct {
	// contains filtered or unexported fields
}

ErrorOptions error parmas

func (*ErrorOptions) NewSimpleError

func (p *ErrorOptions) NewSimpleError() SimpleError

NewSimpleError new simple errors by options

type Errors

type Errors []error

Errors error slice

func NewErrors

func NewErrors(errs ...error) Errors

NewErrors 生成错误数据对象

func (Errors) Append

func (p Errors) Append(errs ...error) Errors

Append 增补错误对象

func (Errors) Error

func (p Errors) Error() string

func (Errors) Errors added in v0.21.13

func (p Errors) Errors() error

Errors 判断是否为空

type Option added in v0.21.15

type Option func(*Options)

func Callers added in v0.21.15

func Callers(c int) Option

func ParamsOption added in v0.21.18

func ParamsOption(ps Params) Option

type OptionFunc

type OptionFunc func(*ErrorOptions)

OptionFunc set params

func OptionCode

func OptionCode(code uint64) OptionFunc

OptionCode set error code into options

func OptionContext

func OptionContext(ctx map[string]interface{}) OptionFunc

OptionContext set error context into options

func OptionErrs added in v0.21.15

func OptionErrs(errs ...error) OptionFunc

OptionErrs append errs

func OptionID

func OptionID(id string) OptionFunc

OptionID set id into options

func OptionMesssage

func OptionMesssage(msg string) OptionFunc

OptionMesssage set error message into options

func OptionNamespace

func OptionNamespace(ns string) OptionFunc

OptionNamespace set error code into options

type Options added in v0.21.15

type Options struct {
	Params  Params
	Callers int
}

type Params

type Params map[string]interface{}

Params template params

type SimpleError

type SimpleError interface {
	ID() string
	Namespace() string
	Message() string
	FullError() string
	Error() string
}

SimpleError simple error functions

func New

func New(text string) SimpleError

New 生成简单对象

func Newf

func Newf(text string, params ...interface{}) SimpleError

Newf 生成简单对象

Jump to

Keyboard shortcuts

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