errors

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package errors provides a convenient way to deal with SDK errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsServiceError

func IsServiceError(err error) bool

IsServiceError checks if the Error code represents a service call error.

func New

func New(code codes.Code, msg string, args ...interface{}) error

New returns a new ClientError with code and formatted message.

func NewInvalidArgumentError

func NewInvalidArgumentError(msg string, args ...interface{}) error

NewInvalidArgumentError returns a new ClientError represents an InvalidArgument.

func NewInvalidArgumentErrorWithCause

func NewInvalidArgumentErrorWithCause(cause error, msg string, args ...interface{}) error

NewInvalidArgumentErrorWithCause returns a new ClientError represents an InvalidArgument.

func NewWithCause

func NewWithCause(code codes.Code, err error, msg string, args ...interface{}) error

NewWithCause returns a new ClientError with code and formatted message.

Types

type ClientError

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

ClientError represents any error regarding the used of SDK or validating the operation call.

func (*ClientError) As

func (err *ClientError) As(out interface{}) bool

func (*ClientError) Code

func (err *ClientError) Code() codes.Code

Code returns codes.Code.

Unknown is returned also if original error is not from GRPC.

func (*ClientError) Error

func (err *ClientError) Error() string

func (*ClientError) Message

func (err *ClientError) Message() string

func (*ClientError) Unwrap

func (err *ClientError) Unwrap() error

type StatusError

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

StatusError wraps status returned from gRPC call with optional prefix for easier access.

func FromError

func FromError(err error) *StatusError

FromError converts given error into StatusError if possible, otherwise false is returned. Returns (nil, false) also if given error is nil.

func NewGRPCError

func NewGRPCError(entryErr interface{}) *StatusError

NewGRPCError unwrap original GRPC status and wraps into GRPCErrorWrapper for easier access.

func (*StatusError) Code

func (err *StatusError) Code() codes.Code

Code returns GRPC Status code.

Unknown is returned also if original error is not from GRPC.

func (*StatusError) Error

func (err *StatusError) Error() string

func (*StatusError) Message

func (err *StatusError) Message() string

Message returns GRPC Status message.

func (*StatusError) Origin

func (err *StatusError) Origin() error

Origin returns underlying error, if any.

func (*StatusError) Status

func (err *StatusError) Status() *status.Status

Status returns GRPC status.

func (*StatusError) WithPrefix

func (err *StatusError) WithPrefix(prefix string) *StatusError

WithPrefix set prefix which will be printed in when Error is called.

Jump to

Keyboard shortcuts

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