kerrors

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalException  = &basicError{"internal exception"}
	ErrServiceDiscovery   = &basicError{"service discovery error"}
	ErrGetConnection      = &basicError{"get connection error"}
	ErrLoadbalance        = &basicError{"loadbalance error"}
	ErrNoMoreInstance     = &basicError{"no more instances to retry"}
	ErrRPCTimeout         = &basicError{"rpc timeout"}
	ErrCanceledByBusiness = &basicError{"canceled by business"}
	ErrTimeoutByBusiness  = &basicError{"timeout by business"}
	ErrACL                = &basicError{"request forbidden"}
	ErrCircuitBreak       = &basicError{"forbidden by circuitbreaker"}
	ErrRemoteOrNetwork    = &basicError{"remote or network error"}
	ErrOverlimit          = &basicError{"request over limit"}
	ErrPanic              = &basicError{"panic"}
	ErrBiz                = &basicError{"biz error"}

	ErrRetry = &basicError{"retry error"}
	// ErrRPCFinish happens when retry enabled and there is one call has finished
	ErrRPCFinish = &basicError{"rpc call finished"}
	// ErrRoute happens when router fail to route this call
	ErrRoute = &basicError{"rpc route failed"}
)

Basic error types

View Source
var (
	ErrNotSupported         = ErrInternalException.WithCause(errors.New("operation not supported"))
	ErrNoResolver           = ErrInternalException.WithCause(errors.New("no resolver available"))
	ErrNoDestService        = ErrInternalException.WithCause(errors.New("no dest service"))
	ErrNoDestAddress        = ErrInternalException.WithCause(errors.New("no dest address"))
	ErrNoConnection         = ErrInternalException.WithCause(errors.New("no connection available"))
	ErrConnOverLimit        = ErrOverlimit.WithCause(errors.New("to many connections"))
	ErrQPSOverLimit         = ErrOverlimit.WithCause(errors.New("request too frequent"))
	ErrNoIvkRequest         = ErrInternalException.WithCause(errors.New("invoker request not set"))
	ErrServiceCircuitBreak  = ErrCircuitBreak.WithCause(errors.New("service circuitbreak"))
	ErrInstanceCircuitBreak = ErrCircuitBreak.WithCause(errors.New("instance circuitbreak"))
	ErrNoInstance           = ErrServiceDiscovery.WithCause(errors.New("no instance available"))
)

More detailed error types

View Source
var TimeoutCheckFunc func(err error) bool

TimeoutCheckFunc is used to check whether the given err is a timeout error.

Functions

func IsKitexError

func IsKitexError(err error) bool

IsKitexError reports whether the given err is an error generated by kitex.

func IsTimeoutError

func IsTimeoutError(err error) bool

IsTimeoutError check if the error is timeout

Types

type BizStatusError added in v0.4.3

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

func (*BizStatusError) AppendBizMessage added in v0.4.3

func (e *BizStatusError) AppendBizMessage(extraMsg string)

func (*BizStatusError) BizExtra added in v0.4.3

func (e *BizStatusError) BizExtra() map[string]string

func (*BizStatusError) BizMessage added in v0.4.3

func (e *BizStatusError) BizMessage() string

func (*BizStatusError) BizStatusCode added in v0.4.3

func (e *BizStatusError) BizStatusCode() int32

func (*BizStatusError) Error added in v0.4.3

func (e *BizStatusError) Error() string

func (*BizStatusError) SetBizExtra added in v0.4.3

func (e *BizStatusError) SetBizExtra(key, value string)

type BizStatusErrorIface added in v0.4.3

type BizStatusErrorIface interface {
	BizStatusCode() int32
	BizMessage() string
	BizExtra() map[string]string
	Error() string
}

func FromBizStatusError added in v0.4.3

func FromBizStatusError(err error) (bizErr BizStatusErrorIface, ok bool)

FromBizStatusError converts err to BizStatusErrorIface.

func NewBizStatusError added in v0.4.3

func NewBizStatusError(code int32, msg string) BizStatusErrorIface

NewBizStatusError returns BizStatusErrorIface by passing in code and msg.

func NewBizStatusErrorWithExtra added in v0.4.3

func NewBizStatusErrorWithExtra(code int32, msg string, extra map[string]string) BizStatusErrorIface

NewBizStatusErrorWithExtra returns BizStatusErrorIface which contains extra info.

func NewGRPCBizStatusError added in v0.4.3

func NewGRPCBizStatusError(code int32, msg string) BizStatusErrorIface

NewGRPCBizStatusError returns *GRPCBizStatusError which implements both BizStatusErrorIface and GRPCStatusIface, use this function instead of NewBizStatusError to pass status.Details in gRPC scenario.

func NewGRPCBizStatusErrorWithExtra added in v0.4.3

func NewGRPCBizStatusErrorWithExtra(code int32, msg string, extra map[string]string) BizStatusErrorIface

NewGRPCBizStatusErrorWithExtra returns *GRPCBizStatusError which implements both BizStatusErrorIface and GRPCStatusIface, use this function instead of NewBizStatusErrorWithExtra to pass status.Details in gRPC scenario.

type DetailedError

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

DetailedError contains more information.

func (*DetailedError) As

func (de *DetailedError) As(target interface{}) bool

As returns if the given target matches the current error, if so sets target to the error value and returns true

func (*DetailedError) Error

func (de *DetailedError) Error() string

Error implements the error interface.

func (*DetailedError) ErrorType

func (de *DetailedError) ErrorType() error

ErrorType returns the basic error type.

func (*DetailedError) Format added in v0.4.3

func (de *DetailedError) Format(s fmt.State, verb rune)

Format the error.

func (*DetailedError) Is

func (de *DetailedError) Is(target error) bool

Is returns if the given error matches the current error.

func (*DetailedError) Stack

func (de *DetailedError) Stack() string

Stack record stack info

func (*DetailedError) Timeout

func (de *DetailedError) Timeout() bool

Timeout supports the os.IsTimeout checking.

func (*DetailedError) Unwrap

func (de *DetailedError) Unwrap() error

Unwrap returns the cause of detailed error.

func (*DetailedError) WithExtraMsg

func (de *DetailedError) WithExtraMsg(extraMsg string)

WithExtraMsg to add extra msg to supply error msg

type GRPCBizStatusError added in v0.4.3

type GRPCBizStatusError struct {
	BizStatusError
	// contains filtered or unexported fields
}

func (*GRPCBizStatusError) GRPCStatus added in v0.4.3

func (e *GRPCBizStatusError) GRPCStatus() *status.Status

func (*GRPCBizStatusError) SetGRPCStatus added in v0.4.3

func (e *GRPCBizStatusError) SetGRPCStatus(status *status.Status)

type GRPCStatusIface added in v0.4.3

type GRPCStatusIface interface {
	GRPCStatus() *status.Status
	SetGRPCStatus(status *status.Status)
}

Jump to

Keyboard shortcuts

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