kerrors

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

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

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

func (*BizStatusError) AppendBizMessage

func (e *BizStatusError) AppendBizMessage(extraMsg string)

func (*BizStatusError) BizExtra

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

func (*BizStatusError) BizMessage

func (e *BizStatusError) BizMessage() string

func (*BizStatusError) BizStatusCode

func (e *BizStatusError) BizStatusCode() int32

func (*BizStatusError) Error

func (e *BizStatusError) Error() string

func (*BizStatusError) SetBizExtra

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

type BizStatusErrorIface

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

func FromBizStatusError

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

FromBizStatusError converts err to BizStatusErrorIface.

func NewBizStatusError

func NewBizStatusError(code int32, msg string) BizStatusErrorIface

NewBizStatusError returns BizStatusErrorIface by passing in code and msg.

func NewBizStatusErrorWithExtra

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

NewBizStatusErrorWithExtra returns BizStatusErrorIface which contains extra info.

func NewGRPCBizStatusError

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

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

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

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

func (*GRPCBizStatusError) GRPCStatus

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

func (*GRPCBizStatusError) SetGRPCStatus

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

type GRPCStatusIface

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