Documentation ¶
Overview ¶
Package errors provides a convenient way to deal with SDK errors.
Index ¶
- func IsServiceError(err error) bool
- func New(code codes.Code, msg string, args ...interface{}) error
- func NewInvalidArgumentError(msg string, args ...interface{}) error
- func NewInvalidArgumentErrorWithCause(cause error, msg string, args ...interface{}) error
- func NewWithCause(code codes.Code, err error, msg string, args ...interface{}) error
- type ClientError
- type StatusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsServiceError ¶
IsServiceError checks if the Error code represents a service call error.
func NewInvalidArgumentError ¶
NewInvalidArgumentError returns a new ClientError represents an InvalidArgument.
func NewInvalidArgumentErrorWithCause ¶
NewInvalidArgumentErrorWithCause returns a new ClientError represents an InvalidArgument.
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.