errors

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: LGPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(err error) codes.Code

Code returns the Code of the error if it is a RpcError error, codes.OK if err is nil, or codes.Unknown otherwise.

func Error

func Error(c codes.Code, msg string) error

Error returns an error representing c and msg. If c is OK, returns nil.

func ErrorWithCause

func ErrorWithCause(c codes.Code, cause error, msg string) error

Error returns an error with cause and msg.

func Errorf

func Errorf(c codes.Code, format string, a ...interface{}) error

Errorf returns Error(c, fmt.Sprintf(format, a...)).

func ErrorfWithCause

func ErrorfWithCause(c codes.Code, cause error, format string, a ...interface{}) error

Error returns an error with cause and formatted msg.

func ExtractErrCode

func ExtractErrCode(err error) (uint32, bool)

ExtractErrCode 从 error 消息中提取 uint32 的错误码

Types

type RpcError

type RpcError struct {
	Code    codes.Code `json:"code"`    // 错误码
	Message string     `json:"message"` // 额外的错误提示消息
	Cause   error      `json:"cause"`   // 导致本 error 的内部 error
}

func New

func New(c codes.Code, msg string) *RpcError

New returns a Status representing c and msg.

func Newf

func Newf(c codes.Code, format string, a ...interface{}) *RpcError

Newf returns New(c, fmt.Sprintf(format, a...)).

func (*RpcError) DetailedError

func (e *RpcError) DetailedError() string

func (*RpcError) Error

func (e *RpcError) Error() string

func (*RpcError) GetCause

func (e *RpcError) GetCause() error

func (*RpcError) GetCode

func (e *RpcError) GetCode() codes.Code

func (*RpcError) GetMessage

func (e *RpcError) GetMessage() string

func (*RpcError) Unwrap

func (e *RpcError) Unwrap() error

func (*RpcError) WithCause

func (e *RpcError) WithCause(err error) *RpcError

WithCause encupsale an err as cause

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

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