error

package
v0.0.0-...-cc24d94 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceModuleKey = "source_module"
)

Variables

This section is empty.

Functions

func LogDeliverTxError

func LogDeliverTxError(logger log.Logger, err error, blockHeight int64, handler string, msg sdk.Msg)

LogDeliverTxError logs an error, appending the block height and ABCI callback to the error message.

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. This method is appropriate for logging errors that may or may not be wrapped in an ErrorWithLogContext.

func WrapErrorWithSourceModuleContext

func WrapErrorWithSourceModuleContext(err error, module string) error

WrapErrorWithPricesSourceModuleContext wraps an error with a LogContextualizer that contains a key-value pair for the specified source module. This can be used, for example, for wrapping validation failure errors that are logged within the process proposal handler (or from any other location that uses LogErrorWithOptionalContext) with metadata that helps to more easily identify the source of the error and correlate logs.

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
}

LogContextualizer describes an object that can add context - that is, descriptive key-value pairs, to a logger. This interface is implemented by ErrorWithLogContext, which wraps some errors that are returned from the protocol. This can be used, for example, to add context to log statements from the process proposal handler that helps with debugging erroneous unexpected and/or non-deterministic behaviors.

Jump to

Keyboard shortcuts

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