errors

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const InvalidCode = -1

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As exports As from std errors.

func Is

func Is(err, target error) bool

Is exports Is from std errors.

func LogError

func LogError(log *zerolog.Event, err error) *zerolog.Event

LogError adds error with detail fields in Zerolog logger

func SetGRPCDebugMode

func SetGRPCDebugMode(enable bool)

SetGRPCDebugMode sets grpc error debug mode. If enable, GRPCStatus will include error cause in details.

func Unwrap

func Unwrap(err error) error

Unwrap exports Unwrap from std errors.

Types

type Error

type Error struct {
	GRPCError
	// contains filtered or unexported fields
}

func New

func New(message string) *Error

New creates new error

func Wrap

func Wrap(e error, message string) *Error

Wrap create new error with underlying error cause

func (*Error) Cause

func (e *Error) Cause() error

Cause returns error cause of error

func (*Error) Code

func (e *Error) Code() int

Code returns code of error

func (*Error) Error

func (e *Error) Error() string

Error implements error interface

func (*Error) GRPCStatus

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

GRPCStatus implements GrpcError interface. Returning this error in grpc API will add detail and cause into details field in GRPC error response. Once GRPCStatus is called, the status data is cached, new changes will not be reflected in new calls.

func (*Error) Log

func (e *Error) Log(log *zerolog.Event) *zerolog.Event

Log adds error with detail fields in Zerolog logger

func (*Error) Message

func (e *Error) Message() string

Message returns message of error

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns error cause of error to implement Unwrap interface

func (*Error) With

func (e *Error) With(key string, value interface{}) *Error

With adds custom field in detail

func (*Error) WithCode

func (e *Error) WithCode(code int) *Error

WithCode updates code in error

func (*Error) WithGRPCCode

func (e *Error) WithGRPCCode(code codes.Code) *Error

WithGRPCCode updates GRPC code in error

type GRPCError

type GRPCError interface {
	GRPCStatus() *status.Status
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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