errors

package
v0.0.0-...-60f4931 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) (error, bool)

Cause returns the cause of the given error if it's defined.

func GetPrintableMessage

func GetPrintableMessage(err error) string

GetPrintableMessage returns a user friendly error to print to the user. If any error in the error chain has a user friendly error message, it prints that. Otherwise, it prints the errors' generic message.

func HandleFatalError

func HandleFatalError(err error)

func Marshal

func Marshal(err error) *proto.Error

Marshal converts an error (that may contain custom Kelda error types) into an error that can be transmitted over gRPC, and unmarshalled on the other side.

func New

func New(f string, args ...interface{}) error

New returns a new Go error. It is provided so that callers don't have to import both the Go "errors" package and this package.

func NewFriendlyError

func NewFriendlyError(f string, args ...interface{}) error

NewFriendlyError returns a new user friendly error that can be retrieved by GetPrintableMessage.

func RootCause

func RootCause(err error) error

RootCause returns the root cause of the given error.

func UnaryClientInterceptor

func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{},
	cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req interface{},
	_ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func Unmarshal

func Unmarshal(grpcErr error, protoErr *proto.Error) error

Unmarshal reconstructs an error created by Marshal. It also takes the error returned by gRPC for easy handling in client logic.

func WithContext

func WithContext(context string, err error) error

WithContext returns an error that can be unwrapped by `Cause`.

Types

type ContextError

type ContextError interface {
	Cause() error
	Context() string

	Error() string
}

ContextError is an error that has information on what caused it.

type FriendlyError

type FriendlyError interface {
	FriendlyMessage() string
	Error() string
}

A FriendlyError is an error with that can be directly printed to the user without any other context.

Jump to

Keyboard shortcuts

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