util

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextualizeIfNeeded added in v1.8.0

func ContextualizeIfNeeded(msg string, err error) error

ContextualizeIfNeeded is a helper function to turn an error into a ContextualError if it is not already one

func LogWithContextIfNeeded added in v1.8.0

func LogWithContextIfNeeded(msg string, err error, l *slog.Logger)

LogWithContextIfNeeded is a helper function to log an error line for an error or ContextualError

Types

type ContextualError added in v1.5.1

type ContextualError struct {
	RealError error
	Fields    map[string]any
	Context   string
}

func NewContextualError added in v1.5.1

func NewContextualError(msg string, fields map[string]any, realError error) *ContextualError

func (*ContextualError) Error added in v1.5.1

func (ce *ContextualError) Error() string

func (*ContextualError) Log added in v1.5.1

func (ce *ContextualError) Log(l *slog.Logger)

Log emits ce as a single error-level log line with Fields and RealError promoted to top-level attributes, producing a flat shape callers can grep or parse without walking into a nested object.

func (*ContextualError) Unwrap added in v1.5.1

func (ce *ContextualError) Unwrap() error

Jump to

Keyboard shortcuts

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