errors

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidGID           = New("invalid gate id")
	ErrInvalidNID           = New("invalid node id")
	ErrInvalidMessage       = New("invalid message")
	ErrNotFoundSession      = New("not found session")
	ErrInvalidSessionKind   = New("invalid session kind")
	ErrReceiveTargetEmpty   = New("the receive target is empty")
	ErrInvalidArgument      = New("invalid argument")
	ErrNotFoundRoute        = New("not found route")
	ErrNotFoundEvent        = New("not found event")
	ErrNotFoundEndpoint     = New("not found endpoint")
	ErrNotFoundUserLocation = New("not found user's location")
	ErrClientShut           = New("client is shut")
	ErrConnectionHanged     = New("connection is hanged")
	ErrConnectionClosed     = New("connection is closed")
	ErrTooManyConnection    = New("too many connection")
	ErrSeqOverflow          = New("seq overflow")
	ErrRouteOverflow        = New("route overflow")
	ErrBufferTooLarge       = New("buffer too large")
)

Functions

func As

func As(err error, target interface{}) bool

As Wrapping for errors.As standard library

func Cause

func Cause(err error) error

Cause 返回根因错误

func Code

func Code(err error) *codes.Code

Code 返回错误码

func Is

func Is(err, target error) bool

Is Wrapping for errors.Is standard library

func New

func New(text string) error

New Wrapping for errors.New standard library

func Next

func Next(err error) error

Next 返回下一个错误

func Replace

func Replace(err error, text string, condition ...codes.Code) error

Replace 替换文本

func Stack

func Stack(err error) *stack.Stack

Stack 返回堆栈

func Unwrap

func Unwrap(err error) error

Unwrap Wrapping for errors.Unwrap standard library

Types

type Error

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

func NewError

func NewError(args ...interface{}) *Error

NewError 新建一个错误 可传入一下参数: text : 文本字符串 code : 错误码 error: 原生错误

func NewErrorWithStack

func NewErrorWithStack(args ...interface{}) *Error

NewErrorWithStack 新建一个带堆栈的错误 可传入一下参数: text : 文本字符串 code : 错误码 error: 原生错误

func (*Error) As

func (e *Error) As(target interface{}) bool

As 返回当前错误是否是某一类错误

func (*Error) Cause

func (e *Error) Cause() error

Cause 返回根因错误

func (*Error) Code

func (e *Error) Code() *codes.Code

Code 返回错误码

func (*Error) Error

func (e *Error) Error() (text string)

func (*Error) Format

func (e *Error) Format(s fmt.State, verb rune)

Format 格式化输出 %s : 打印本级错误信息 %v : 打印所有错误信息 %+v: 打印所有错误信息和堆栈信息

func (*Error) Is

func (e *Error) Is(target error) bool

Is 返回当前错误是否等于目标错误

func (*Error) Next

func (e *Error) Next() error

Next 返回下一个错误

func (*Error) Replace

func (e *Error) Replace(text string, condition ...*codes.Code) error

Replace 替换文本

func (*Error) Stack

func (e *Error) Stack() *stack.Stack

Stack 返回堆栈

func (*Error) String

func (e *Error) String() string

String 格式化错误信息

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap 解包错误

Jump to

Keyboard shortcuts

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