error

package
v0.3.0-dev2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogErrorWithOptionalContext

func LogErrorWithOptionalContext(
	logger log.Logger,
	msg string,
	err error,
)

LogErrorWithOptionalContext logs an error, optionally adding context to the logger iff the error implements the LogContextualizer interface.

func WrapErrorWithSourceModuleContext

func WrapErrorWithSourceModuleContext(err error, module string) error

WrapErrorWithPricesSourceModuleContext wraps an error with a LogContextualizer that the spercified source module. This is useful for logging the error within the process proposal handler (or any other location that uses LogErrorWithOptionalContext) with metadata that can be used to identify the source of the error.

Types

type ErrorWithLogContext

type ErrorWithLogContext struct {
	LogContextualizer
	// contains filtered or unexported fields
}

ErrorWithLogContext wraps an error with log context and implements the LogContextualizer interface. ErrorWithLogContext unwraps to the original error.

func NewErrorWithLogContext

func NewErrorWithLogContext(err error) *ErrorWithLogContext

NewErrorWithLogContext returns a new ErrorWithLogContext wrapping the given error.

func (*ErrorWithLogContext) AddLoggingContext

func (ewlc *ErrorWithLogContext) AddLoggingContext(logger log.Logger) log.Logger

AddLoggingContext returns a modified logger with the error's logging context added.

func (*ErrorWithLogContext) Error

func (ewlc *ErrorWithLogContext) Error() string

Error returns the underlying error's Error() string.

func (*ErrorWithLogContext) Unwrap

func (ewlc *ErrorWithLogContext) Unwrap() error

Unwrap returns the underlying error.

func (*ErrorWithLogContext) WithLogKeyValue

func (ewlc *ErrorWithLogContext) WithLogKeyValue(key interface{}, value interface{}) *ErrorWithLogContext

WithLogKeyValue adds a key-value pair to the error's log context. The returned ErrorWithLogContext is the same error.

type LogContextualizer

type LogContextualizer interface {
	AddLoggingContext(logger log.Logger) log.Logger
	Unwrap() error
}

Jump to

Keyboard shortcuts

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