errors

package
v4.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(err error) codes.Code

func Error

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

func ErrorWithCause

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

func Errorf

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

func ErrorfWithCause

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

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"`

	// 导致本 error 的内部 error
	Cause error `json:"cause"`
}

func New

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

func Newf

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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